Exemple #1
0
 def run(self):
     mac_list = self.config['copy_files']['Mac_files'].keys()
     gos_list = self.config['copy_files']['gOS_files'].keys()
     for i in gos_list:
         if self.config['copy_files']['gOS_files'][i] is True:
             shell(self.scp_cmd % (i, self.path_road))
     for j in mac_list:
         if self.config['copy_files']['Mac_files'][j] is True:
             copy_file(j, self.path_road)
     write_txt(os.path.join(self.path_road, 'dti.txt'), self.read_dti())
Exemple #2
0
 def firmware(self):
     read_cmd = self.config['Firmware']
     final = OrderedDict()
     for i in read_cmd:
         a, b = shell(read_cmd[i])
         if a == 0:
             final[i] = b[0]
     return final
Exemple #3
0
 def ssd_info(self):
     ssd_read = self.config['SSD']
     final = OrderedDict()
     if ssd_read['read'] is True:
         a, b = shell(ssd_read['cmd'])
         if a == 0 and len(b) > 0:
             final['SSD'] = b[0]
     return final
Exemple #4
0
 def read_sn(self):
     serial_number = None
     tb = re.compile(self.config['sn_read']['read_rule'])
     a, b = shell(self.config['sn_read']['cmd'])
     if a == 0:
         sn = tb.findall(str(b))
         if len(sn) > 0:
             serial_number = sn[0]
     return serial_number
Exemple #5
0
 def getSn(self):
     sn = "None"
     code, getInfo = shell(self.configInfo["Serial Number"]["command"])
     if code == 0:
         for i in getInfo:
             tmp = match(self.configInfo["Serial Number"]["read rule"], i)
             if len(tmp) > 0:
                 sn = tmp[0]
                 break
     return sn
Exemple #6
0
    def running(self):
        mac_list = self.config['copy_files']['Mac_files'].keys()
        gos_list = self.config['copy_files']['gOS_files'].keys()
        for i in gos_list:
            if self.config['copy_files']['gOS_files'][i] is True:
                shell(self.scp_cmd % (i, self.path_road))
        for j in mac_list:
            if self.config['copy_files']['Mac_files'][j] is True:
                copy_file(j, self.path_road)

        fail_file = os.path.join(self.path_road, 'failures.csv')
        fails = read_csv(fail_file, self.config['csv_read']['read_key'])
        name = self.config['xlsx_read']['sheet_name']
        column = self.config['xlsx_read']['column']
        station = self.config['xlsx_read']['station']
        station_column = self.config['xlsx_read']['station_column']
        errors = read_xlsx(self.error_code_path, station, station_column, name,
                           column)
        self.compress(fails, errors)
Exemple #7
0
 def tgz_uncompress(self, obj, force=False):
     '''
     :param obj:     file path for uncompress
     :param force:   force to remove obj file when force is True
     :return:        no return
     '''
     path = os.path.dirname(obj)
     name = os.path.basename(obj)
     a, b = shell(self.uncompress % (path, name))
     if force and a == 0:
         os.system('rm -rf %s' % obj)
Exemple #8
0
 def read_dti(self):
     dti_version = 'None'
     a, obj = shell('cd %s; cat < %s' %
                    (self.config['dti_read']['file_path'],
                     self.config['dti_read']['file_name']))
     if a == 0:
         for i in obj:
             t = re.findall(self.config['dti_read']['read_rule'], i)
             if t:
                 dti_version = t[0]
                 break
     return dti_version
Exemple #9
0
 def hardware(self):
     info_dict = self.config['cmd']
     final = OrderedDict()
     count = 0
     for i in info_dict:
         temp = [key for key in info_dict[i]['read_list'] if info_dict[i]['read_list'][key] is True]
         a, b = shell(i)
         for j in b:
             for n in temp:
                 if n in j:
                     if ':' in j:
                         count += 1
                         final[str(count)] = {n: str(j).split(':')[1].replace(' ', '', 1)}
     return final
Exemple #10
0
 def get_gOS_files(self, sn):
     target = self.create(sn)
     files = self.configInfo["gOS Files"].items()
     for i in files:
         if i[1] is True:
             shell(self.copy_cmd % (i[0], target))