Ejemplo n.º 1
0
 def delete(self):
     ret = 'Delete Done'
     keyname = getsKeyNameFromPath(self.path)
     k = Key(self.bucket_obj)
     k.key = keyname
     k.delete()
     return ret
Ejemplo n.º 2
0
 def put(self):
     ret = 'Put Done'
     keyname = getsKeyNameFromPath(self.path)
     k = Key(self.bucket_obj)
     k.key = keyname
     k.set_contents_from_filename(self.path)
     return ret
Ejemplo n.º 3
0
 def get(self):
     ret = ''
     if (self.path is None) or (self.path == ''):
         # We are trying to list everything - eg. for ls command
         for item in self.bucket_obj.list():
             sitem = str(item)
             sitem = sitem[1:-1]
             words = sitem.strip().split(',')
             pretty_item = words[1]
             ret += pretty_item + '\n'
     else:
         ret += 'Download Done'
         k = Key(self.bucket_obj)
         k.key = getsKeyNameFromPath(self.path)
         k.get_contents_to_filename(getsKeyNameFromPath(self.path))
     return ret
Ejemplo n.º 4
0
def db_file_add(ppath):
    path = ops.getsKeyNameFromPath(ppath)
    fil = open(PATHDB, 'a')
    fil.write(path)
    fil.write('\n')
    fil.close()
    return 0
Ejemplo n.º 5
0
 def put(self):
     path = getsKeyNameFromPath(self.path)
     self.block_blob_service.create_blob_from_path(
         self.bucket_name,  # container  should user provide the name
         path,  # to be uploaded object
         path,  # real file path
     )
     return "Put Done"
Ejemplo n.º 6
0
def db_file_remove(ppath):
    path = ops.getsKeyNameFromPath(ppath)
    fil = open(PATHDB, 'r+')
    cfil = open(PATHDB + '_1', 'w+')
    for line in fil:
        if path not in line:
            cfil.write(line)
    fil.close()
    cfil.close()
    os.system('rm ' + PATHDB)
    os.system('mv ' + PATHDB + '_1 ' + PATHDB)
    return 0
Ejemplo n.º 7
0
    def get(self):
        ret = ''
        if (self.path is None) or (self.path == ''):
            generator = self.block_blob_service.list_blobs(self.bucket_name)
            for blob in generator:
                ret += blob.name + "\n"
        else:
            path = getsKeyNameFromPath(self.path)
            self.block_blob_service.get_blob_to_path(self.bucket_name, path,
                                                     path)
            ret += 'Download Done'

        return ret
Ejemplo n.º 8
0
 def delete(self):
     path = getsKeyNameFromPath(self.path)
     self.block_blob_service.delete_blob(self.bucket_name, path)
     return "Delete Done"