コード例 #1
0
def test_readdir():
    client = HttpFsClient(
        HOSTNAME,
        PORT,
        ca_file=None
    )

    fake_path = "/some/path"

    # Fake _send_request
    def fake_send_request(request_type, **kwargs):
        for arg in ["uid", "gid"]:
            assert arg in kwargs.keys()
        assert request_type == HttpFsRequest.OP_READDIR
        assert kwargs["path"] == fake_path
        resp = HttpFsResponse()
        resp._response_data["dir_listing"] = list()
        return resp

    client._send_request = fake_send_request
    client.readdir(fake_path)
コード例 #2
0
def test_open():
    client = HttpFsClient(
        HOSTNAME,
        PORT,
        ca_file=None
    )

    fake_path = "/some/path"
    fake_flags = 0 | 1 | 2 | 666

    # Fake _send_request
    def fake_send_request(request_type, **kwargs):
        for arg in ["uid", "gid"]:
            assert arg in kwargs.keys()
        assert request_type == HttpFsRequest.OP_OPEN
        assert kwargs["path"] == fake_path
        assert kwargs["flags"] == fake_flags
        return HttpFsResponse()

    client._send_request = fake_send_request
    client.open(fake_path, fake_flags)
コード例 #3
0
def test_mknod():
    client = HttpFsClient(
        HOSTNAME,
        PORT,
        ca_file=None
    )

    fake_path = "/some/path"
    fake_mode = 0o644
    fake_dev = False

    # Fake _send_request
    def fake_send_request(request_type, **kwargs):
        assert request_type == HttpFsRequest.OP_MKNOD
        assert kwargs["path"] == fake_path
        assert kwargs["mode"] == fake_mode
        assert kwargs["dev"] == fake_dev
        return HttpFsResponse()

    client._send_request = fake_send_request
    client.mknod(fake_path, fake_mode, fake_dev)
コード例 #4
0
def test_chmod():
    client = HttpFsClient(
        HOSTNAME,
        PORT,
        ca_file=None
    )

    fake_path = "/some/path"
    fake_mode = 0o600

    # Fake _send_request
    def fake_send_request(request_type, **kwargs):
        assert request_type == HttpFsRequest.OP_CHMOD
        for required_key in ["uid", "gid"]:
            assert required_key in kwargs.keys()
        assert kwargs["path"] == fake_path
        assert kwargs["mode"] == fake_mode
        return HttpFsResponse()

    client._send_request = fake_send_request
    client.chmod(fake_path, fake_mode)
コード例 #5
0
def test_create():
    client = HttpFsClient(
        HOSTNAME,
        PORT,
        ca_file=None
    )

    fake_path = "/some/path"
    fake_mode = 0o600

    # Fake _send_request
    def fake_send_request(request_type, **kwargs):
        assert request_type == HttpFsRequest.OP_CREATE
        for required_key in ["uid", "gid"]:
            assert required_key in kwargs.keys()
        assert kwargs["path"] == fake_path
        assert kwargs["mode"] == fake_mode
        resp = HttpFsResponse()
        resp._response_data["file_descriptor"] = 0
        return resp

    client._send_request = fake_send_request
    client.create(fake_path, fake_mode)
コード例 #6
0
ファイル: __main__.py プロジェクト: httpfs/httpfs
PARSER.add_argument("--verbose",
                    dest="verbose",
                    help="Be verbose",
                    action="store_true")
ARGS = PARSER.parse_args()

log_level = logging.WARN
if ARGS.verbose:
    log_level = logging.DEBUG

logging.basicConfig(level=log_level, format=LOG_FMT, datefmt=DATE_FMT)

try:
    # Create the mount directory
    if not os.path.exists(ARGS.mount):
        logging.error("Mount point '%s' does not exist", ARGS.mount)
        sys.exit(1)

    [HOSTNAME, PORT] = ARGS.server.rsplit(':', 1)

    # Mount the filesystem
    FUSE(HttpFsClient(HOSTNAME,
                      PORT,
                      api_key=ARGS.api_key,
                      ca_file=ARGS.ca_file),
         ARGS.mount,
         foreground=True,
         allow_other=True)
except Exception as exception:
    logging.error("ERROR: %s", exception)