From 1915539c5f1da95c975256dbb3ef38137acec2db Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Tue, 25 Oct 2016 13:57:23 -0700 Subject: [PATCH] Rearrange files to prepare to merge into Ray. --- .clang-format | 9 - .gitignore | 38 -- .gitmodules | 3 - .travis.yml | 50 -- .travis/check-git-clang-format-output.sh | 18 - .travis/git-clang-format | 476 ------------------ LICENSE | 201 -------- install-dependencies.sh | 21 - Makefile => src/common/Makefile | 0 {build => src/common/build}/.gitkeep | 0 common.c => src/common/common.c | 0 common.h => src/common/common.h | 0 {doc => src/common/doc}/tasks.md | 0 event_loop.c => src/common/event_loop.c | 0 event_loop.h => src/common/event_loop.h | 0 io.c => src/common/io.c | 0 io.h => src/common/io.h | 0 .../common/lib}/python/common_extension.c | 0 .../common/lib}/python/common_extension.h | 0 .../common/lib}/python/common_module.c | 0 {lib => src/common/lib}/python/setup.py | 0 logging.c => src/common/logging.c | 0 logging.h => src/common/logging.h | 0 {state => src/common/state}/db.h | 0 {state => src/common/state}/object_table.h | 0 {state => src/common/state}/redis.c | 0 {state => src/common/state}/redis.h | 0 {state => src/common/state}/task_log.h | 0 {state => src/common/state}/task_table.h | 0 task.c => src/common/task.c | 0 task.h => src/common/task.h | 0 {test => src/common/test}/common_tests.c | 0 {test => src/common/test}/db_tests.c | 0 {test => src/common/test}/example_task.h | 0 {test => src/common/test}/io_tests.c | 0 {test => src/common/test}/redis_tests.c | 0 {test => src/common/test}/task_tests.c | 0 {test => src/common/test}/test.py | 0 {thirdparty => src/common/thirdparty}/ae/ae.c | 0 {thirdparty => src/common/thirdparty}/ae/ae.h | 0 .../common/thirdparty}/ae/ae_epoll.c | 0 .../common/thirdparty}/ae/ae_evport.c | 0 .../common/thirdparty}/ae/ae_kqueue.c | 0 .../common/thirdparty}/ae/ae_select.c | 0 .../common/thirdparty}/ae/config.h | 0 .../common/thirdparty}/ae/zmalloc.h | 0 .../common/thirdparty}/build-redis.sh | 0 .../common/thirdparty}/greatest.h | 0 {thirdparty => src/common/thirdparty}/hiredis | 0 .../common/thirdparty}/utarray.h | 0 .../common/thirdparty}/uthash.h | 0 .../common/thirdparty}/utlist.h | 0 .../common/thirdparty}/utstring.h | 0 53 files changed, 816 deletions(-) delete mode 100644 .clang-format delete mode 100644 .gitignore delete mode 100644 .gitmodules delete mode 100644 .travis.yml delete mode 100755 .travis/check-git-clang-format-output.sh delete mode 100755 .travis/git-clang-format delete mode 100644 LICENSE delete mode 100755 install-dependencies.sh rename Makefile => src/common/Makefile (100%) rename {build => src/common/build}/.gitkeep (100%) rename common.c => src/common/common.c (100%) rename common.h => src/common/common.h (100%) rename {doc => src/common/doc}/tasks.md (100%) rename event_loop.c => src/common/event_loop.c (100%) rename event_loop.h => src/common/event_loop.h (100%) rename io.c => src/common/io.c (100%) rename io.h => src/common/io.h (100%) rename {lib => src/common/lib}/python/common_extension.c (100%) rename {lib => src/common/lib}/python/common_extension.h (100%) rename {lib => src/common/lib}/python/common_module.c (100%) rename {lib => src/common/lib}/python/setup.py (100%) rename logging.c => src/common/logging.c (100%) rename logging.h => src/common/logging.h (100%) rename {state => src/common/state}/db.h (100%) rename {state => src/common/state}/object_table.h (100%) rename {state => src/common/state}/redis.c (100%) rename {state => src/common/state}/redis.h (100%) rename {state => src/common/state}/task_log.h (100%) rename {state => src/common/state}/task_table.h (100%) rename task.c => src/common/task.c (100%) rename task.h => src/common/task.h (100%) rename {test => src/common/test}/common_tests.c (100%) rename {test => src/common/test}/db_tests.c (100%) rename {test => src/common/test}/example_task.h (100%) rename {test => src/common/test}/io_tests.c (100%) rename {test => src/common/test}/redis_tests.c (100%) rename {test => src/common/test}/task_tests.c (100%) rename {test => src/common/test}/test.py (100%) rename {thirdparty => src/common/thirdparty}/ae/ae.c (100%) rename {thirdparty => src/common/thirdparty}/ae/ae.h (100%) rename {thirdparty => src/common/thirdparty}/ae/ae_epoll.c (100%) rename {thirdparty => src/common/thirdparty}/ae/ae_evport.c (100%) rename {thirdparty => src/common/thirdparty}/ae/ae_kqueue.c (100%) rename {thirdparty => src/common/thirdparty}/ae/ae_select.c (100%) rename {thirdparty => src/common/thirdparty}/ae/config.h (100%) rename {thirdparty => src/common/thirdparty}/ae/zmalloc.h (100%) rename {thirdparty => src/common/thirdparty}/build-redis.sh (100%) rename {thirdparty => src/common/thirdparty}/greatest.h (100%) rename {thirdparty => src/common/thirdparty}/hiredis (100%) rename {thirdparty => src/common/thirdparty}/utarray.h (100%) rename {thirdparty => src/common/thirdparty}/uthash.h (100%) rename {thirdparty => src/common/thirdparty}/utlist.h (100%) rename {thirdparty => src/common/thirdparty}/utstring.h (100%) diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 89b87e25d..000000000 --- a/.clang-format +++ /dev/null @@ -1,9 +0,0 @@ -BasedOnStyle: Chromium -DerivePointerAlignment: true -IndentCaseLabels: false -PointerAlignment: Right -SpaceAfterCStyleCast: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: false -AllowShortIfStatementsOnASingleLine: false diff --git a/.gitignore b/.gitignore deleted file mode 100644 index fff8ef269..000000000 --- a/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -*~ - -# Object files -*.o -*.ko -*.obj -*.elf - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su - -# Build files -build/* diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 4026f8268..000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "thirdparty/hiredis"] - path = thirdparty/hiredis - url = https://github.com/redis/hiredis diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d0e14edf5..000000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -sudo: required - -language: generic - -matrix: - include: - - os: linux - dist: trusty - python: "2.7" - - os: linux - dist: trusty - python: "3.5" - - os: osx - osx_image: xcode7 - python: "2.7" - - os: osx - osx_image: xcode7 - python: "3.5" - - os: linux - dist: trusty - env: LINT=1 - before_install: - # In case we ever want to use a different version of clang-format: - #- wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - #- echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty main" | sudo tee -a /etc/apt/sources.list > /dev/null - - sudo apt-get update -qq - - sudo apt-get install -qq clang-format-3.8 - install: [] - script: - - .travis/check-git-clang-format-output.sh - - os: linux - dist: trusty - python: "2.7" - env: VALGRIND=1 - before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq valgrind - script: - - make valgrind - -install: - - ./install-dependencies.sh - - make - - make test - - cd lib/python - - python setup.py install --user - - cd ../.. - -script: - - python test/test.py diff --git a/.travis/check-git-clang-format-output.sh b/.travis/check-git-clang-format-output.sh deleted file mode 100755 index d71f78357..000000000 --- a/.travis/check-git-clang-format-output.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -if [ "$TRAVIS_PULL_REQUEST" == "false" ] ; then - # Not in a pull request, so compare against parent commit - base_commit="HEAD^" - echo "Running clang-format against parent commit $(git rev-parse $base_commit)" -else - base_commit="$TRAVIS_BRANCH" - echo "Running clang-format against branch $base_commit, with hash $(git rev-parse $base_commit)" -fi -output="$(.travis/git-clang-format --binary clang-format-3.8 --commit $base_commit --diff --exclude ^thirdparty/)" -if [ "$output" == "no modified files to format" ] || [ "$output" == "clang-format did not modify any files" ] ; then - echo "clang-format passed." - exit 0 -else - echo "clang-format failed:" - echo "$output" - exit 1 -fi diff --git a/.travis/git-clang-format b/.travis/git-clang-format deleted file mode 100755 index 37b352835..000000000 --- a/.travis/git-clang-format +++ /dev/null @@ -1,476 +0,0 @@ -#!/usr/bin/env python -# -#===- git-clang-format - ClangFormat Git Integration ---------*- python -*--===# -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -#===------------------------------------------------------------------------===# - -r""" -clang-format git integration -============================ - -This file provides a clang-format integration for git. Put it somewhere in your -path and ensure that it is executable. Then, "git clang-format" will invoke -clang-format on the changes in current files or a specific commit. - -For further details, run: -git clang-format -h - -Requires Python 2.7 -""" - -import argparse -import collections -import contextlib -import errno -import os -import re -import subprocess -import sys - -usage = 'git clang-format [OPTIONS] [] [--] [...]' - -desc = ''' -Run clang-format on all lines that differ between the working directory -and , which defaults to HEAD. Changes are only applied to the working -directory. -The following git-config settings set the default of the corresponding option: - clangFormat.binary - clangFormat.commit - clangFormat.extension - clangFormat.style -''' - -# Name of the temporary index file in which save the output of clang-format. -# This file is created within the .git directory. -temp_index_basename = 'clang-format-index' - - -Range = collections.namedtuple('Range', 'start, count') - - -def main(): - config = load_git_config() - - # In order to keep '--' yet allow options after positionals, we need to - # check for '--' ourselves. (Setting nargs='*' throws away the '--', while - # nargs=argparse.REMAINDER disallows options after positionals.) - argv = sys.argv[1:] - try: - idx = argv.index('--') - except ValueError: - dash_dash = [] - else: - dash_dash = argv[idx:] - argv = argv[:idx] - - default_extensions = ','.join([ - # From clang/lib/Frontend/FrontendOptions.cpp, all lower case - 'c', 'h', # C - 'm', # ObjC - 'mm', # ObjC++ - 'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp', # C++ - # Other languages that clang-format supports - 'proto', 'protodevel', # Protocol Buffers - 'js', # JavaScript - 'ts', # TypeScript - ]) - - p = argparse.ArgumentParser( - usage=usage, formatter_class=argparse.RawDescriptionHelpFormatter, - description=desc) - p.add_argument('--binary', - default=config.get('clangformat.binary', 'clang-format'), - help='path to clang-format'), - p.add_argument('--commit', - default=config.get('clangformat.commit', 'HEAD'), - help='default commit to use if none is specified'), - p.add_argument('--diff', action='store_true', - help='print a diff instead of applying the changes') - p.add_argument('--extensions', - default=config.get('clangformat.extensions', - default_extensions), - help=('comma-separated list of file extensions to format, ' - 'excluding the period and case-insensitive')), - p.add_argument('--exclude', help='Exclude files matching this regex.') - p.add_argument('-f', '--force', action='store_true', - help='allow changes to unstaged files') - p.add_argument('-p', '--patch', action='store_true', - help='select hunks interactively') - p.add_argument('-q', '--quiet', action='count', default=0, - help='print less information') - p.add_argument('--style', - default=config.get('clangformat.style', None), - help='passed to clang-format'), - p.add_argument('-v', '--verbose', action='count', default=0, - help='print extra information') - # We gather all the remaining positional arguments into 'args' since we need - # to use some heuristics to determine whether or not was present. - # However, to print pretty messages, we make use of metavar and help. - p.add_argument('args', nargs='*', metavar='', - help='revision from which to compute the diff') - p.add_argument('ignored', nargs='*', metavar='...', - help='if specified, only consider differences in these files') - opts = p.parse_args(argv) - - opts.verbose -= opts.quiet - del opts.quiet - - commit, files = interpret_args(opts.args, dash_dash, opts.commit) - changed_lines = compute_diff_and_extract_lines(commit, files) - if opts.verbose >= 1: - ignored_files = set(changed_lines) - filter_by_extension(changed_lines, opts.extensions.lower().split(',')) - if opts.exclude: - for filename in changed_lines.keys(): - if re.match(opts.exclude, filename): - del changed_lines[filename] - if opts.verbose >= 1: - ignored_files.difference_update(changed_lines) - if ignored_files: - print 'Ignoring changes in the following files:' - for filename in ignored_files: - print ' ', filename - if changed_lines: - print 'Running clang-format on the following files:' - for filename in changed_lines: - print ' ', filename - if not changed_lines: - print 'no modified files to format' - return - # The computed diff outputs absolute paths, so we must cd before accessing - # those files. - cd_to_toplevel() - old_tree = create_tree_from_workdir(changed_lines) - new_tree = run_clang_format_and_save_to_tree(changed_lines, - binary=opts.binary, - style=opts.style) - if opts.verbose >= 1: - print 'old tree:', old_tree - print 'new tree:', new_tree - if old_tree == new_tree: - if opts.verbose >= 0: - print 'clang-format did not modify any files' - elif opts.diff: - print_diff(old_tree, new_tree) - else: - changed_files = apply_changes(old_tree, new_tree, force=opts.force, - patch_mode=opts.patch) - if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1: - print 'changed files:' - for filename in changed_files: - print ' ', filename - - -def load_git_config(non_string_options=None): - """Return the git configuration as a dictionary. - All options are assumed to be strings unless in `non_string_options`, in which - is a dictionary mapping option name (in lower case) to either "--bool" or - "--int".""" - if non_string_options is None: - non_string_options = {} - out = {} - for entry in run('git', 'config', '--list', '--null').split('\0'): - if entry: - name, value = entry.split('\n', 1) - if name in non_string_options: - value = run('git', 'config', non_string_options[name], name) - out[name] = value - return out - - -def interpret_args(args, dash_dash, default_commit): - """Interpret `args` as "[commit] [--] [files...]" and return (commit, files). - It is assumed that "--" and everything that follows has been removed from - args and placed in `dash_dash`. - If "--" is present (i.e., `dash_dash` is non-empty), the argument to its - left (if present) is taken as commit. Otherwise, the first argument is - checked if it is a commit or a file. If commit is not given, - `default_commit` is used.""" - if dash_dash: - if len(args) == 0: - commit = default_commit - elif len(args) > 1: - die('at most one commit allowed; %d given' % len(args)) - else: - commit = args[0] - object_type = get_object_type(commit) - if object_type not in ('commit', 'tag'): - if object_type is None: - die("'%s' is not a commit" % commit) - else: - die("'%s' is a %s, but a commit was expected" % (commit, object_type)) - files = dash_dash[1:] - elif args: - if disambiguate_revision(args[0]): - commit = args[0] - files = args[1:] - else: - commit = default_commit - files = args - else: - commit = default_commit - files = [] - return commit, files - - -def disambiguate_revision(value): - """Returns True if `value` is a revision, False if it is a file, or dies.""" - # If `value` is ambiguous (neither a commit nor a file), the following - # command will die with an appropriate error message. - run('git', 'rev-parse', value, verbose=False) - object_type = get_object_type(value) - if object_type is None: - return False - if object_type in ('commit', 'tag'): - return True - die('`%s` is a %s, but a commit or filename was expected' % - (value, object_type)) - - -def get_object_type(value): - """Returns a string description of an object's type, or None if it is not - a valid git object.""" - cmd = ['git', 'cat-file', '-t', value] - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = p.communicate() - if p.returncode != 0: - return None - return stdout.strip() - - -def compute_diff_and_extract_lines(commit, files): - """Calls compute_diff() followed by extract_lines().""" - diff_process = compute_diff(commit, files) - changed_lines = extract_lines(diff_process.stdout) - diff_process.stdout.close() - diff_process.wait() - if diff_process.returncode != 0: - # Assume error was already printed to stderr. - sys.exit(2) - return changed_lines - - -def compute_diff(commit, files): - """Return a subprocess object producing the diff from `commit`. - The return value's `stdin` file object will produce a patch with the - differences between the working directory and `commit`, filtered on `files` - (if non-empty). Zero context lines are used in the patch.""" - cmd = ['git', 'diff-index', '-p', '-U0', commit, '--'] - cmd.extend(files) - p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) - p.stdin.close() - return p - - -def extract_lines(patch_file): - """Extract the changed lines in `patch_file`. - The return value is a dictionary mapping filename to a list of (start_line, - line_count) pairs. - The input must have been produced with ``-U0``, meaning unidiff format with - zero lines of context. The return value is a dict mapping filename to a - list of line `Range`s.""" - matches = {} - for line in patch_file: - match = re.search(r'^\+\+\+\ [^/]+/(.*)', line) - if match: - filename = match.group(1).rstrip('\r\n') - match = re.search(r'^@@ -[0-9,]+ \+(\d+)(,(\d+))?', line) - if match: - start_line = int(match.group(1)) - line_count = 1 - if match.group(3): - line_count = int(match.group(3)) - if line_count > 0: - matches.setdefault(filename, []).append(Range(start_line, line_count)) - return matches - - -def filter_by_extension(dictionary, allowed_extensions): - """Delete every key in `dictionary` that doesn't have an allowed extension. - `allowed_extensions` must be a collection of lowercase file extensions, - excluding the period.""" - allowed_extensions = frozenset(allowed_extensions) - for filename in dictionary.keys(): - base_ext = filename.rsplit('.', 1) - if len(base_ext) == 1 or base_ext[1].lower() not in allowed_extensions: - del dictionary[filename] - - -def cd_to_toplevel(): - """Change to the top level of the git repository.""" - toplevel = run('git', 'rev-parse', '--show-toplevel') - os.chdir(toplevel) - - -def create_tree_from_workdir(filenames): - """Create a new git tree with the given files from the working directory. - Returns the object ID (SHA-1) of the created tree.""" - return create_tree(filenames, '--stdin') - - -def run_clang_format_and_save_to_tree(changed_lines, binary='clang-format', - style=None): - """Run clang-format on each file and save the result to a git tree. - Returns the object ID (SHA-1) of the created tree.""" - def index_info_generator(): - for filename, line_ranges in changed_lines.iteritems(): - mode = oct(os.stat(filename).st_mode) - blob_id = clang_format_to_blob(filename, line_ranges, binary=binary, - style=style) - yield '%s %s\t%s' % (mode, blob_id, filename) - return create_tree(index_info_generator(), '--index-info') - - -def create_tree(input_lines, mode): - """Create a tree object from the given input. - If mode is '--stdin', it must be a list of filenames. If mode is - '--index-info' is must be a list of values suitable for "git update-index - --index-info", such as " ". Any other mode - is invalid.""" - assert mode in ('--stdin', '--index-info') - cmd = ['git', 'update-index', '--add', '-z', mode] - with temporary_index_file(): - p = subprocess.Popen(cmd, stdin=subprocess.PIPE) - for line in input_lines: - p.stdin.write('%s\0' % line) - p.stdin.close() - if p.wait() != 0: - die('`%s` failed' % ' '.join(cmd)) - tree_id = run('git', 'write-tree') - return tree_id - - -def clang_format_to_blob(filename, line_ranges, binary='clang-format', - style=None): - """Run clang-format on the given file and save the result to a git blob. - Returns the object ID (SHA-1) of the created blob.""" - clang_format_cmd = [binary, filename] - if style: - clang_format_cmd.extend(['-style='+style]) - clang_format_cmd.extend([ - '-lines=%s:%s' % (start_line, start_line+line_count-1) - for start_line, line_count in line_ranges]) - try: - clang_format = subprocess.Popen(clang_format_cmd, stdin=subprocess.PIPE, - stdout=subprocess.PIPE) - except OSError as e: - if e.errno == errno.ENOENT: - die('cannot find executable "%s"' % binary) - else: - raise - clang_format.stdin.close() - hash_object_cmd = ['git', 'hash-object', '-w', '--path='+filename, '--stdin'] - hash_object = subprocess.Popen(hash_object_cmd, stdin=clang_format.stdout, - stdout=subprocess.PIPE) - clang_format.stdout.close() - stdout = hash_object.communicate()[0] - if hash_object.returncode != 0: - die('`%s` failed' % ' '.join(hash_object_cmd)) - if clang_format.wait() != 0: - die('`%s` failed' % ' '.join(clang_format_cmd)) - return stdout.rstrip('\r\n') - - -@contextlib.contextmanager -def temporary_index_file(tree=None): - """Context manager for setting GIT_INDEX_FILE to a temporary file and deleting - the file afterward.""" - index_path = create_temporary_index(tree) - old_index_path = os.environ.get('GIT_INDEX_FILE') - os.environ['GIT_INDEX_FILE'] = index_path - try: - yield - finally: - if old_index_path is None: - del os.environ['GIT_INDEX_FILE'] - else: - os.environ['GIT_INDEX_FILE'] = old_index_path - os.remove(index_path) - - -def create_temporary_index(tree=None): - """Create a temporary index file and return the created file's path. - If `tree` is not None, use that as the tree to read in. Otherwise, an - empty index is created.""" - gitdir = run('git', 'rev-parse', '--git-dir') - path = os.path.join(gitdir, temp_index_basename) - if tree is None: - tree = '--empty' - run('git', 'read-tree', '--index-output='+path, tree) - return path - - -def print_diff(old_tree, new_tree): - """Print the diff between the two trees to stdout.""" - # We use the porcelain 'diff' and not plumbing 'diff-tree' because the output - # is expected to be viewed by the user, and only the former does nice things - # like color and pagination. - subprocess.check_call(['git', 'diff', old_tree, new_tree, '--']) - - -def apply_changes(old_tree, new_tree, force=False, patch_mode=False): - """Apply the changes in `new_tree` to the working directory. - Bails if there are local changes in those files and not `force`. If - `patch_mode`, runs `git checkout --patch` to select hunks interactively.""" - changed_files = run('git', 'diff-tree', '-r', '-z', '--name-only', old_tree, - new_tree).rstrip('\0').split('\0') - if not force: - unstaged_files = run('git', 'diff-files', '--name-status', *changed_files) - if unstaged_files: - print >>sys.stderr, ('The following files would be modified but ' - 'have unstaged changes:') - print >>sys.stderr, unstaged_files - print >>sys.stderr, 'Please commit, stage, or stash them first.' - sys.exit(2) - if patch_mode: - # In patch mode, we could just as well create an index from the new tree - # and checkout from that, but then the user will be presented with a - # message saying "Discard ... from worktree". Instead, we use the old - # tree as the index and checkout from new_tree, which gives the slightly - # better message, "Apply ... to index and worktree". This is not quite - # right, since it won't be applied to the user's index, but oh well. - with temporary_index_file(old_tree): - subprocess.check_call(['git', 'checkout', '--patch', new_tree]) - index_tree = old_tree - else: - with temporary_index_file(new_tree): - run('git', 'checkout-index', '-a', '-f') - return changed_files - - -def run(*args, **kwargs): - stdin = kwargs.pop('stdin', '') - verbose = kwargs.pop('verbose', True) - strip = kwargs.pop('strip', True) - for name in kwargs: - raise TypeError("run() got an unexpected keyword argument '%s'" % name) - p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - stdin=subprocess.PIPE) - stdout, stderr = p.communicate(input=stdin) - if p.returncode == 0: - if stderr: - if verbose: - print >>sys.stderr, '`%s` printed to stderr:' % ' '.join(args) - print >>sys.stderr, stderr.rstrip() - if strip: - stdout = stdout.rstrip('\r\n') - return stdout - if verbose: - print >>sys.stderr, '`%s` returned %s' % (' '.join(args), p.returncode) - if stderr: - print >>sys.stderr, stderr.rstrip() - sys.exit(2) - - -def die(message): - print >>sys.stderr, 'error:', message - sys.exit(2) - - -if __name__ == '__main__': - main() diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 8dada3eda..000000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/install-dependencies.sh b/install-dependencies.sh deleted file mode 100755 index f84da1684..000000000 --- a/install-dependencies.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd) - -platform="unknown" -unamestr="$(uname)" -if [[ "$unamestr" == "Linux" ]]; then - echo "Platform is linux." - platform="linux" -elif [[ "$unamestr" == "Darwin" ]]; then - echo "Platform is macosx." - platform="macosx" -else - echo "Unrecognized platform." - exit 1 -fi - -if [[ $platform == "linux" ]]; then - sudo apt-get update - sudo apt-get install -y git python-dev -fi diff --git a/Makefile b/src/common/Makefile similarity index 100% rename from Makefile rename to src/common/Makefile diff --git a/build/.gitkeep b/src/common/build/.gitkeep similarity index 100% rename from build/.gitkeep rename to src/common/build/.gitkeep diff --git a/common.c b/src/common/common.c similarity index 100% rename from common.c rename to src/common/common.c diff --git a/common.h b/src/common/common.h similarity index 100% rename from common.h rename to src/common/common.h diff --git a/doc/tasks.md b/src/common/doc/tasks.md similarity index 100% rename from doc/tasks.md rename to src/common/doc/tasks.md diff --git a/event_loop.c b/src/common/event_loop.c similarity index 100% rename from event_loop.c rename to src/common/event_loop.c diff --git a/event_loop.h b/src/common/event_loop.h similarity index 100% rename from event_loop.h rename to src/common/event_loop.h diff --git a/io.c b/src/common/io.c similarity index 100% rename from io.c rename to src/common/io.c diff --git a/io.h b/src/common/io.h similarity index 100% rename from io.h rename to src/common/io.h diff --git a/lib/python/common_extension.c b/src/common/lib/python/common_extension.c similarity index 100% rename from lib/python/common_extension.c rename to src/common/lib/python/common_extension.c diff --git a/lib/python/common_extension.h b/src/common/lib/python/common_extension.h similarity index 100% rename from lib/python/common_extension.h rename to src/common/lib/python/common_extension.h diff --git a/lib/python/common_module.c b/src/common/lib/python/common_module.c similarity index 100% rename from lib/python/common_module.c rename to src/common/lib/python/common_module.c diff --git a/lib/python/setup.py b/src/common/lib/python/setup.py similarity index 100% rename from lib/python/setup.py rename to src/common/lib/python/setup.py diff --git a/logging.c b/src/common/logging.c similarity index 100% rename from logging.c rename to src/common/logging.c diff --git a/logging.h b/src/common/logging.h similarity index 100% rename from logging.h rename to src/common/logging.h diff --git a/state/db.h b/src/common/state/db.h similarity index 100% rename from state/db.h rename to src/common/state/db.h diff --git a/state/object_table.h b/src/common/state/object_table.h similarity index 100% rename from state/object_table.h rename to src/common/state/object_table.h diff --git a/state/redis.c b/src/common/state/redis.c similarity index 100% rename from state/redis.c rename to src/common/state/redis.c diff --git a/state/redis.h b/src/common/state/redis.h similarity index 100% rename from state/redis.h rename to src/common/state/redis.h diff --git a/state/task_log.h b/src/common/state/task_log.h similarity index 100% rename from state/task_log.h rename to src/common/state/task_log.h diff --git a/state/task_table.h b/src/common/state/task_table.h similarity index 100% rename from state/task_table.h rename to src/common/state/task_table.h diff --git a/task.c b/src/common/task.c similarity index 100% rename from task.c rename to src/common/task.c diff --git a/task.h b/src/common/task.h similarity index 100% rename from task.h rename to src/common/task.h diff --git a/test/common_tests.c b/src/common/test/common_tests.c similarity index 100% rename from test/common_tests.c rename to src/common/test/common_tests.c diff --git a/test/db_tests.c b/src/common/test/db_tests.c similarity index 100% rename from test/db_tests.c rename to src/common/test/db_tests.c diff --git a/test/example_task.h b/src/common/test/example_task.h similarity index 100% rename from test/example_task.h rename to src/common/test/example_task.h diff --git a/test/io_tests.c b/src/common/test/io_tests.c similarity index 100% rename from test/io_tests.c rename to src/common/test/io_tests.c diff --git a/test/redis_tests.c b/src/common/test/redis_tests.c similarity index 100% rename from test/redis_tests.c rename to src/common/test/redis_tests.c diff --git a/test/task_tests.c b/src/common/test/task_tests.c similarity index 100% rename from test/task_tests.c rename to src/common/test/task_tests.c diff --git a/test/test.py b/src/common/test/test.py similarity index 100% rename from test/test.py rename to src/common/test/test.py diff --git a/thirdparty/ae/ae.c b/src/common/thirdparty/ae/ae.c similarity index 100% rename from thirdparty/ae/ae.c rename to src/common/thirdparty/ae/ae.c diff --git a/thirdparty/ae/ae.h b/src/common/thirdparty/ae/ae.h similarity index 100% rename from thirdparty/ae/ae.h rename to src/common/thirdparty/ae/ae.h diff --git a/thirdparty/ae/ae_epoll.c b/src/common/thirdparty/ae/ae_epoll.c similarity index 100% rename from thirdparty/ae/ae_epoll.c rename to src/common/thirdparty/ae/ae_epoll.c diff --git a/thirdparty/ae/ae_evport.c b/src/common/thirdparty/ae/ae_evport.c similarity index 100% rename from thirdparty/ae/ae_evport.c rename to src/common/thirdparty/ae/ae_evport.c diff --git a/thirdparty/ae/ae_kqueue.c b/src/common/thirdparty/ae/ae_kqueue.c similarity index 100% rename from thirdparty/ae/ae_kqueue.c rename to src/common/thirdparty/ae/ae_kqueue.c diff --git a/thirdparty/ae/ae_select.c b/src/common/thirdparty/ae/ae_select.c similarity index 100% rename from thirdparty/ae/ae_select.c rename to src/common/thirdparty/ae/ae_select.c diff --git a/thirdparty/ae/config.h b/src/common/thirdparty/ae/config.h similarity index 100% rename from thirdparty/ae/config.h rename to src/common/thirdparty/ae/config.h diff --git a/thirdparty/ae/zmalloc.h b/src/common/thirdparty/ae/zmalloc.h similarity index 100% rename from thirdparty/ae/zmalloc.h rename to src/common/thirdparty/ae/zmalloc.h diff --git a/thirdparty/build-redis.sh b/src/common/thirdparty/build-redis.sh similarity index 100% rename from thirdparty/build-redis.sh rename to src/common/thirdparty/build-redis.sh diff --git a/thirdparty/greatest.h b/src/common/thirdparty/greatest.h similarity index 100% rename from thirdparty/greatest.h rename to src/common/thirdparty/greatest.h diff --git a/thirdparty/hiredis b/src/common/thirdparty/hiredis similarity index 100% rename from thirdparty/hiredis rename to src/common/thirdparty/hiredis diff --git a/thirdparty/utarray.h b/src/common/thirdparty/utarray.h similarity index 100% rename from thirdparty/utarray.h rename to src/common/thirdparty/utarray.h diff --git a/thirdparty/uthash.h b/src/common/thirdparty/uthash.h similarity index 100% rename from thirdparty/uthash.h rename to src/common/thirdparty/uthash.h diff --git a/thirdparty/utlist.h b/src/common/thirdparty/utlist.h similarity index 100% rename from thirdparty/utlist.h rename to src/common/thirdparty/utlist.h diff --git a/thirdparty/utstring.h b/src/common/thirdparty/utstring.h similarity index 100% rename from thirdparty/utstring.h rename to src/common/thirdparty/utstring.h