예제 #1
0
    def inject(self):
        #insert attributes for the file
        attrs = self.sprayData.getAttributes()
        dsname = self.sprayData.getDataSetName()
        injector = attrs['injector']

        fileTozip = [x for x in self.files.keys()]
        zipDest = "%s/%s"%(self.uploadDir, self.sprayData.getArchiveName())

        zip(fileTozip, zipDest)
        tar(fileTozip, zipDest)

        # Description of the dataset.
        desc = dsname
        if 'description' in attrs:
            desc = attrs['description']

        doc = {
            'name' : dsname,
            'injector': injector,
            'description': desc,
            'files' : self.files.values(),
            'date_added' : int(time.time()),
            'zip_file' : ("%s.zip")%self.sprayData.getArchiveName(),
            'tar_file' : ("%s.tar.gz")%self.sprayData.getArchiveName(),
        }

        doc.update(attrs)

        res = self.db.dataset.insert(doc)

        self.refreshKeyData(doc);
예제 #2
0
파일: client.py 프로젝트: JunguangJiang/FTP
 def put_folder(self, local_file, remote_file=None):
     '''将本地文件夹local_file传至远程主机的remote_file目录下'''
     if not os.path.exists(local_file):  #文件不存在
         self.__latest_response = "{}文件不存在".format(local_file)
         return False
     local_zip_file_name = util.zip(local_file)  #首先将本地的文件夹压缩
     if not remote_file:
         remote_file = '.'
     remote_zip_file_name = remote_file + "/" + local_file.split(
         '/')[-1] + '.zip'
     if not self.put(local_file=local_zip_file_name,
                     remote_file=remote_zip_file_name):  #然后传输压缩后的文件
         return False
     if not self.unzip(remote_zip_file_name).startswith(
             "250"):  #在远程服务器上解压文件
         return False
     self.delete(remote_zip_file_name)  #最后清理服务器上压缩文件
     os.remove(local_zip_file_name)  #以及本地的文件
     return True
예제 #3
0
def test_dir():
    out_path = 'C:/tmp/zip_dir.zip'
    target_file_path = 'C:/test/dir1'
    util.zip(out_path, target_file_path)
예제 #4
0
def test_dir_excl_root_path():
    out_path = 'C:/tmp/zip_dir_excl_root_path.zip'
    target_file_path = 'C:/test/dir1'
    util.zip(out_path, target_file_path, excl_root_path=True)
예제 #5
0
def test_listed():
    zip_path = 'C:/tmp/zip_listed.zip'
    target_list = ['C:/test/a.txt', 'C:/test/b.txt']
    util.zip(zip_path, target_list)
    return 'OK'
예제 #6
0
                                                output_line_header)  # noqa

                                        write_output = 1
                        else:
                            log_file.write(
                                'ERROR#E12:Could not find DAILY in input file: %s. Data is ignored\r\n'
                                % os.path.join(dirname, filename))  # noqa
                except Exception, err:
                    print str(err)
                    log_file.write('ERROR: Unable to process file: %s \n' %
                                   os.path.join(dirname, filename))  # noqa
        # data file close
        data_file.close()

        # zip data file
        util.zip(os.path.abspath(str(master_file)), "o3tot.zip")
        tmp_filename = "o3tot.zip"

        # log file close
        log_file.close()
        print 'log file is located here: %s' % os.path.abspath(
            'totalOzone_processing_log_%s' % current_time)  # noqa


'''
class TotalOzone_MasterFile(object):

    def __init__(self):
        """
        Instantiate totalozone master file object
        """
예제 #7
0
def test1():
    zip_path = 'C:/tmp/zip1.zip'
    target_file_path = 'C:/test/a.txt'
    util.zip(zip_path, target_file_path)
    return 'OK'