Beispiel #1
0
def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(description='A Mock-S3 server.')
    parser.add_argument('--hostname',
                        dest='hostname',
                        action='store',
                        default='localhost',
                        help='Hostname to listen on.')
    parser.add_argument('--port',
                        dest='port',
                        action='store',
                        default=10001,
                        type=int,
                        help='Port to run server on.')
    parser.add_argument('--root',
                        dest='root',
                        action='store',
                        default='%s/s3store' % os.environ['HOME'],
                        help='Defaults to $HOME/s3store.')
    parser.add_argument('--pull-from-aws',
                        dest='pull_from_aws',
                        action='store_true',
                        default=False,
                        help='Pull non-existent keys from aws.')
    args = parser.parse_args()

    server = ThreadedHTTPServer((args.hostname, args.port), S3Handler)
    server.set_file_store(FileStore(args.root))
    server.set_mock_hostname(args.hostname)
    server.set_pull_from_aws(args.pull_from_aws)

    print('Starting server, use <Ctrl-C> to stop')
    server.serve_forever()
Beispiel #2
0
def main(argv=sys.argv[1:]):
    parser = argparse.ArgumentParser(description='A Mock-S3 server.')
    parser.add_argument('--hostname', dest='hostname', action='store',
                        default='localhost',
                        help='Hostname to listen on.')
    parser.add_argument('--port', dest='port', action='store',
                        default=10001, type=int,
                        help='Port to run server on.')
    parser.add_argument('--root', dest='root', action='store',
                        default='%s/s3store' % str(Path.home()),
                        help='Defaults to $HOME/s3store.')
    args = parser.parse_args()

    server = ThreadedHTTPServer((args.hostname, args.port), S3Handler)
    server.set_file_store(FileStore(args.root))
    server.set_mock_hostname(args.hostname)

    print('Starting server, use <Ctrl-C> to stop')
    try:
        server.serve_forever()
    except (KeyboardInterrupt, SystemExit, TypeError):
        # Run an optional pre-exit function
        pre_exit = getattr(server.file_store, '_pre_exit')
        if pre_exit:
            pre_exit()
    finally:
        server.server_close()
 def __init__(self, path):
     FileStore.__init__(self, path)
Beispiel #4
0
 def __init__(self, path):
     FileStore.__init__(self, path)
Beispiel #5
0
def main():
    file_handler = FileStore(print)
    directory_enumerator = DirectoryEnumerator(file_handler.Add)

    directory_enumerator.Enumerate(".")