Esempio n. 1
0
def write_default_config():
    config = configure()
    if not os.path.exists(os.environ['HOME'] + '/.config'):
        os.makedirs(os.environ['HOME'] + '/.config')
    webhdfs_host = input(
        f"WebHDFS hostname [{config.hdfs_host}]: ") or config.hdfs_host
    cfg.set('DEFAULT', 'HDFS_HOST', webhdfs_host)

    configure_knox = input(
        f"Configure With Apache Knox Gateway (Yes/No)? "
        f"[{config.use_apache_knox and 'Yes' or 'No'}]: ") or (
            config.use_apache_knox and 'Yes' or 'No')
    cfg.set('DEFAULT', 'USE_APACHE_KNOX', configure_knox)

    if strtobool(configure_knox):
        webhdfs_username = input("HDFS username: "******"HDFS password: "******"HDFS web server certificate path [{config.hdfs_cert}: "
        ) or config.hdfs_cert
        cfg.set('DEFAULT', 'HDFS_CERT', webhdfs_cert)
    else:
        webhdfs_port = input(
            f"WebHDFS port [{config.hdfs_port}]: ") or config.hdfs_port
        cfg.set('DEFAULT', 'HDFS_PORT', webhdfs_port)

    with open(os.environ['HOME'] + '/.config/webhdfs.ini', 'w') as configfile:
        cfg.write(configfile)
Esempio n. 2
0
    else:
        mode |= S_IFREG
    mtime = s['modificationTime'] / 1000
    atime = s['accessTime'] / 1000
    blksize = max(s['blockSize'], 1024 * 1024)
    sd = dict(name=s['pathSuffix'],
              st_mode=mode,
              st_ctime=mtime,
              st_mtime=mtime,
              st_atime=atime,
              st_nlink=s['childrenNum'] or 1,
              st_blocks=s['length'] // blksize,
              st_size=s['length'],
              st_creator=s['owner'],
              st_uid=owner_to_uid(s['owner']),
              st_gid=group_to_gid(s['group']),
              st_blksize=blksize)
    return sd


if __name__ == '__main__':
    webhdfs = webhdfs_connect(configure())
    now = time()
    for s in webhdfs.list_dir('/')["FileStatuses"]["FileStatus"]:
        sd = webhdfs_entry_to_dict(s)
        print("{:16}\t{:6}\t{:16}\t{:16}\t{}\t{:9}\t{}".format(
            sd['st_mode'], sd['st_nlink'], sd['st_uid'], sd['st_gid'],
            sd['st_blocks'],
            datetime.datetime.fromtimestamp(
                sd['st_mtime'] / 1000).strftime('%Y-%m-%d %H:%M'), sd['name']))
Esempio n. 3
0
        return self.client.readlink(path)

    def symlink(self, target, source):
        return self.client.symlink(source, target)

    def truncate(self, path, length, fh=None):
        return self.client.truncate(path, length)

    def utimens(self, path, times=None):
        # Set Access (times[0]) and Modification (times[1]) times 
        return self.client.set_time(path, times)

    """


if __name__ == '__main__':
    parser = commandline_parser()
    parser.add_argument('mountpoint', help='Mount directory')

    config = configure(parser)
    logging.basicConfig(level=logging.INFO, filename=config.logfile)
    print("Mounting {} at {}".format(config.hdfs_baseurl, config.mountpoint))

    fuse = FUSE(operations=WebHDFS(config),
                mountpoint=config.mountpoint,
                foreground=False,
                nothreads=True,
                big_writes=True,
                max_read=1024 * 1024,
                max_write=1024 * 1024)