Exemple #1
0
def compress_original_files(original_filename):
    """ compress the output file and gets its compressed size """

    print("== Compress original file %s \n" % (original_filename))

    new_data_set = original_filename

    # get data_set uncompressed size
    size = os.path.getsize(new_data_set)

    bzip2_script = "/homespace/gaubert/ecli-workspace/rodd/etc/compression/bzip2_compression.sh"

    func = subprocess.call

    res = []

    time_bzip2 = ftimer(
        func, [[bzip2_script, new_data_set,
                "%s.bz2" % (new_data_set)]], {},
        res,
        number=1)

    print("\nTime: %s secs \n bzip2 file %s\n" % (time_bzip2, new_data_set))

    if res[0] != 0:
        print("Error. Cannot bzip2 file %s" % (new_data_set))

    szip_script = "/homespace/gaubert/ecli-workspace/rodd/etc/compression/szip_compression.sh"

    time_szip = ftimer(func,
                       [[szip_script, new_data_set,
                         "%s.sz" % (new_data_set)]], {},
                       res,
                       number=1)

    print("\nTime: %s secs \n szip file %s\n" % (time_szip, new_data_set))

    if res[0] != 0:
        print("Error. Cannot bzip2 file %s" % (new_data_set))

    size_bzip2 = os.path.getsize("%s.bz2" % (new_data_set))

    size_szip = os.path.getsize("%s.sz" % (new_data_set))

    print("bzip2 size %d. szip size %d" % (size_bzip2, size_szip))

    #return [( round(float(size)/float(size_bzip2), 2), size_bzip2, time_bzip2 ),( round(float(size)/float(size_szip), 2), size_szip, time_szip )]

    return {
        'name': os.path.basename(original_filename),
        'size': size,
        'orig bz2 size': size_bzip2,
        'orig bz2 ratio': round(float(size) / float(size_bzip2), 2),
        'orig bz2 compression time': round(time_bzip2, 2),
        'orig sz size': size_szip,
        'orig sz ratio': round(float(size) / float(size_szip), 2),
        'orig sz compression time': round(time_szip, 2)
    }
Exemple #2
0
def compress_original_files(original_filename):
    """ compress the output file and gets its compressed size """
    
    print("== Compress original file %s \n" %(original_filename))
    
    new_data_set = original_filename
    
    # get data_set uncompressed size
    size = os.path.getsize(new_data_set)
    
    bzip2_script = "/homespace/gaubert/ecli-workspace/rodd/etc/compression/bzip2_compression.sh"
    
    func = subprocess.call
    
    res = []
            
    time_bzip2 = ftimer(func,[[bzip2_script, new_data_set, "%s.bz2" % (new_data_set) ] ], {}, res, number=1)

    print("\nTime: %s secs \n bzip2 file %s\n"%(time_bzip2 , new_data_set))

    if res[0] != 0:
        print("Error. Cannot bzip2 file %s" % (new_data_set))
       
    szip_script = "/homespace/gaubert/ecli-workspace/rodd/etc/compression/szip_compression.sh"
    
    time_szip = ftimer(func,[ [ szip_script, new_data_set, "%s.sz" % (new_data_set) ] ], {}, res,number=1)

    print("\nTime: %s secs \n szip file %s\n" % (time_szip , new_data_set))

    if res[0] != 0:
        print("Error. Cannot bzip2 file %s" % (new_data_set))
       
    size_bzip2 = os.path.getsize("%s.bz2" %(new_data_set))
    
    size_szip = os.path.getsize("%s.sz" %(new_data_set))
    
    print("bzip2 size %d. szip size %d" % (size_bzip2, size_szip))
    
    #return [( round(float(size)/float(size_bzip2), 2), size_bzip2, time_bzip2 ),( round(float(size)/float(size_szip), 2), size_szip, time_szip )]
    
    return {
            'name' : os.path.basename(original_filename),
            'size' : size,
            'orig bz2 size' : size_bzip2,
            'orig bz2 ratio': round(float(size)/float(size_bzip2), 2),
            'orig bz2 compression time' : round(time_bzip2,2),
            'orig sz size' : size_szip,
            'orig sz ratio' : round(float(size)/float(size_szip), 2),
            'orig sz compression time' : round(time_szip,2)
           }
Exemple #3
0
 def execute_sql(self, a_sql):
     """execute a sql request on the database"""
     
     sql = sqlalchemy.text(a_sql)
     
     if self._activate_timer:
         result = []
         func = self._conn.execute
         the_timer = ftimer(func, [sql], {}, result, number = 1)
         self._log.debug("\nTime: %s secs \nDatabase: %s\nRequest: %s\n"%(the_timer, self._url, a_sql))
         return result[0]
     else:
         result = self._conn.execute(sql)
         return result
Exemple #4
0
    def execute_sql(self, a_sql):
        """execute a sql request on the database"""

        sql = sqlalchemy.text(a_sql)

        if self._activate_timer:
            result = []
            func = self._conn.execute
            the_timer = ftimer(func, [sql], {}, result, number=1)
            self._log.debug("\nTime: %s secs \nDatabase: %s\nRequest: %s\n" %
                            (the_timer, self._url, a_sql))
            return result[0]
        else:
            result = self._conn.execute(sql)
            return result
Exemple #5
0
 def execute(self, a_sql_obj):
     """ proxy to sqlaclhemy execute """
     
     # if sql_obj is a string wrap it in a sqlalchemy.text
     
     if type(a_sql_obj) == type(''):
         sql = sqlalchemy.text(a_sql_obj)
     else:
         sql = a_sql_obj
     
     if self._activate_timer:
         result = []
         func = self._conn.execute
         the_timer = ftimer(func, [sql], {}, result, number = 1)
         self._log.debug("\nTime: %s secs \nDatabase: %s\nRequest: %s\n"%(the_timer, self._url, sql))
         return result[0]
     else:
         result = self._conn.execute(sql)
         return result
Exemple #6
0
    def execute(self, a_sql_obj):
        """ proxy to sqlaclhemy execute """

        # if sql_obj is a string wrap it in a sqlalchemy.text

        if type(a_sql_obj) == type(''):
            sql = sqlalchemy.text(a_sql_obj)
        else:
            sql = a_sql_obj

        if self._activate_timer:
            result = []
            func = self._conn.execute
            the_timer = ftimer(func, [sql], {}, result, number=1)
            self._log.debug("\nTime: %s secs \nDatabase: %s\nRequest: %s\n" %
                            (the_timer, self._url, sql))
            return result[0]
        else:
            result = self._conn.execute(sql)
            return result