Example #1
0
 def point_import(self, file_path, new_date):
     docXls_obj = DocXls('POINT_OUT', '0.40')
     import_record = dict()
     try:
         point_data_list = docXls_obj.load_data(file_path)
     except Exception as e:
         import_record['result'] = 1
         import_record['error_list'] = '上传的文件不正确'
         return import_record
     from Source.spec2db_server.spec_import.pointout import SpecPointout
     obj = SpecPointout()
     import_record = obj.store(point_data_list, new_date)
     return import_record
    def do_import(self, xls_file_name, commit_user_id, update_time):
        result = {"result": "NG", "error": ''}
        try:
            xls_list = DocXls('IT_PROCESS_QA', '0.01').load_data(xls_file_name)
        except Exception as e:
            result["error"] = str(e)
            return result
        self._pg.connect()
        commit_list = []
        try:
            for i, xls_data in enumerate(xls_list, 0):
                new_data_dict = {}
                update_cols = []
                for db_col, xls_data_dict in xls_data.iteritems():
                    update_cols.append(db_col)
                    xls_value = xls_data_dict.get('datavalue')
                    # delete unicode _x000D_
                    if xls_value and type(xls_value) in (str, unicode):
                        xls_value = xls_value.replace('_x000D_', '\n')
                    new_data_dict[db_col] = xls_value
                subject = new_data_dict.get('subject')
                req_id, jira_id_list = self.get_req_id(subject)  # 正则解要件id, jira_id
                if '.' not in req_id:
                    req_id = ''
                if not jira_id_list:
                    jira_id = ''
                else:
                    jira_id = '\n'.join(jira_id_list)
                new_data_dict['req_id'] = req_id
                new_data_dict['jira_id'] = jira_id
                update_cols.append('req_id')
                update_cols.append('jira_id')
                curr_commit_list = self._common_add(self._pg, new_data_dict, update_time, update_cols)
                if curr_commit_list:
                    commit_list += curr_commit_list
            # self._pg.commit()
            # if commit_list:
            #     log_info = {'user_id': commit_user_id, "commit_list": commit_list}
            #     commit_log = HmiLog()
            #     log_commit_data = commit_list[0].get("data")
            #     log_commit_data["update_time"] = update_time
            #     flag, commit_id = commit_log.add_commit_log2(self._pg, log_info)
            #     if flag:
            #         self._pg.commit()
            #         result["result"] = "OK"
            # else:
            #     result["result"] = "OK"
            self._pg.commit()
            result["result"] = "OK"

        except Exception as e:
            print e
            self._pg.conn.rollback()
            result["error"] = "%s%s" % (new_data_dict.get('qa_id'), str(e))
        finally:
            self._pg.close()
            return result
Example #3
0
    def do_import(self, xls_file_name, commit_user_id, update_time):
        result = {"result": "NG", "error": ''}
        try:
            xls_list = DocXls('HMI_INTERNALQA',
                              '0.01').load_data(xls_file_name)
        except Exception as e:
            result["error"] = str(e)
            return result
        self._pg.connect()
        commit_list = []
        try:
            for i, xls_data in enumerate(xls_list, 0):
                print i
                new_data_dict = {}
                update_cols = []
                for db_col, xls_data_dict in xls_data.iteritems():
                    update_cols.append(db_col)
                    xls_value = xls_data_dict.get('datavalue')
                    # delete unicode _x000D_
                    if xls_value and type(xls_value) in (str, unicode):
                        xls_value = xls_value.replace('_x000D_', '\n')

                    new_data_dict[db_col] = xls_value
                curr_commit_list = self._common_add(self._pg, new_data_dict,
                                                    update_time, update_cols)
                if curr_commit_list:
                    commit_list += curr_commit_list
            if commit_list:
                log_info = {
                    'user_id': commit_user_id,
                    "commit_list": commit_list
                }
                commit_log = HmiLog()
                log_commit_data = commit_list[0].get("data")
                log_commit_data["update_time"] = update_time
                flag, commit_id = commit_log.add_commit_log2(
                    self._pg, log_info)
                if flag:
                    self._pg.commit()
                    result["result"] = "OK"
            else:
                result["result"] = "OK"

            # self._pg.commit()
            # result["result"] = "OK"
        except Exception as e:
            print e
            self._pg.conn.rollback()
            result["error"] = "%s%s" % (new_data_dict.get('qa_no'), str(e))
        finally:
            self._pg.close()
            return result
Example #4
0
 def import_point_out_by_user(self, file_path, classify):
     docXls_obj = DocXls(classify, '0.40')
     import_record = dict()
     from pointout import SpecPointout
     point_obj = SpecPointout()
     self.update_time = self.get_current_time()
     if classify == "HU_DEF":
         try:
             data_list = docXls_obj.load_data(file_path)
         except Exception as e:
             print e
             import_record['result'] = 1
             import_record['error_list'] = '上传的文件不正确, %s' % str(e)
             return import_record
     if classify == "TAGL_DEF":
         try:
             data_list = docXls_obj.load_data(file_path)
         except Exception as e:
             print e
             import_record['result'] = 1
             import_record['error_list'] = '上传的文件不正确, %s' % str(e)
             return import_record
     if classify == "TAGL_ANA":
         try:
             data_list = docXls_obj.load_data(file_path)
         except Exception as e:
             print e
             import_record['result'] = 1
             import_record['error_list'] = '上传的文件不正确, %s' % str(e)
             return import_record
     try:
         point_obj.point_store(data_list, update_time, classify)
         import_record['result'] = 0
     except:
         import_record['result'] = 1
     return import_record
    def do_import(self, pg, file_name, xls_file_name, commit_user_id, update_time):
        result = {"result": "NG", "error": ''}
        try:
            xls_list = DocXls('HMI_IT_RESULT_MODE_TRANSITION', '0.01').load_data(xls_file_name)
        except Exception as e:
            result["error"] = str(e)
            return result
        commit_list = []
        try:
            for i, xls_data in enumerate(xls_list, 0):
                print i
                if not xls_data['it_no']['datavalue']:
                    continue
                new_data_dict = {}
                update_cols = []
                for db_col, xls_data_dict in xls_data.iteritems():
                    update_cols.append(db_col)
                    xls_value = xls_data_dict.get('datavalue')
                    # delete unicode _x000D_
                    if xls_value and type(xls_value) in (str, unicode):
                        xls_value = xls_value.replace('_x000D_', '\n')
                    new_data_dict[db_col] = xls_value
                new_data_dict['file_name'] = file_name
                new_data_dict['it_key'] = ', '.join([file_name, new_data_dict['it_no']])
                curr_commit_list = self._common_add(pg, new_data_dict, update_time, update_cols)
                if curr_commit_list:
                    commit_list += curr_commit_list
            if commit_list:
                log_info = {'user_id': commit_user_id, "commit_list": commit_list}
                commit_log = HmiLog()
                log_commit_data = commit_list[0].get("data")
                log_commit_data["update_time"] = update_time
                flag, commit_id = commit_log.add_commit_log2(pg, log_info)
                if flag:
                    result["result"] = "OK"
            else:
                result["result"] = "OK"

        except Exception as e:
            print str(e)
            pg.conn.rollback()
            result["error"] = "%s%s" % (new_data_dict.get('it_no'), str(e))
        finally:
            return result
Example #6
0
 def sheet_import(self, file_path, classify, check_list):
     docXls_obj = DocXls(classify, '0.40')
     import_record = dict()
     role = self.get_role()
     import Source.spec2db_server.arl.arl_server
     spec_obj = Source.spec2db_server.arl.arl_server.ArlSpec()
     dyndata = spec_obj.get_block_white_list()
     api_dyndata = APIDynamicData(dyndata)
     if classify == "HU_DEF":
         try:
             hu_data_list = docXls_obj.load_data(file_path)
         except Exception as e:
             print e
             import_record['result'] = 1
             import_record['error_list'] = '上传的文件不正确, %s' % str(e)
             return import_record
         try:
             obj = HUDocType(api_dyndata)
             index, records, new_e = obj.excel2rows(file_path, r'HU要件定義書', continue_on_error=False)
         except Exception as e:
             if e.message.find('No sheet named') >= 0:
                 new_e = 'No sheet named <'+'HU要件定義書'+'>'
             else:
                 try:
                     new_e = str(e.collection[0].coord)
                 except Exception:
                     new_e = str(e)
         if new_e is None:
             print 'hu导入。。。'
             import_record = SpecHU().new_store(hu_data_list, self.user_id, self.update_time, role, check_list)
         else:
             import_record['result'] = 1
             import_record['error_list'] = new_e
     if classify == "TAGL_DEF":
         try:
             def_data_list = docXls_obj.load_data(file_path)
         except Exception as e:
             print e
             import_record['result'] = 1
             import_record['error_list'] = '上传的文件不正确, %s' % str(e)
             return import_record
         try:
             obj = ReqDocType(api_dyndata)
             index, records, new_e = obj.excel2rows(file_path, r'TAGL要件定義', continue_on_error=False)
         except Exception as e:
             if e.message.find('No sheet named') >= 0:
                 new_e = 'No sheet named <'+'TAGL要件定義'+'>'
             else:
                 try:
                     new_e = str(e.collection[0].coord)
                 except Exception:
                     new_e = str(e)
         if new_e:
             import_record['result'] = 1
             import_record['error_list'] = new_e
             return import_record
         new_e = self.check_basic_def_trans_info(def_data_list)
         if new_e:
             import_record['result'] = 1
             import_record['error_list'] = new_e
             return import_record
         print 'Definition导入。。。'
         import_record = DefinitionSpec().new_store(def_data_list, self.user_id, self.update_time, role, check_list)
     if classify == "TAGL_ANA":
         try:
             ana_data_list = docXls_obj.load_data(file_path)
         except Exception as e:
             print e
             import_record['result'] = 1
             import_record['error_list'] = '上传的文件不正确, %s' % str(e)
             return import_record
         try:
             obj = AnaDocTypeWithLongID(api_dyndata)
             index, records, new_e = obj.excel2rows(file_path, r'TAGL要件分析', continue_on_error=False)
         except Exception as e:
             if e.message.find('No sheet named')>=0:
                 new_e = 'No sheet named <'+'TAGL要件分析'+'>'
             else:
                 try:
                     new_e = str(e.collection[0].coord)
                 except Exception:
                     new_e = str(e)
         if new_e:
             import_record['result'] = 1
             import_record['error_list'] = new_e
             return import_record
         new_e = self.check_basic_ana_trans_info(ana_data_list)
         if new_e:
             import_record['result'] = 1
             import_record['error_list'] = new_e
             return import_record
         print 'Analysis导入。。。'
         import_record = AnalysisSpec().new_store(ana_data_list, self.user_id, self.update_time, role, check_list)
     return import_record
    def do_import(self, xls_file_name, update_cols, commit_user_id,
                  update_time):
        result = {"result": "NG", "error": ''}
        try:
            xls_list = DocXls('HMI_IT_PROGRESS_REPORT',
                              '0.02').load_data(xls_file_name)
        except Exception as e:
            result["error"] = str(e)
            return result
        commit_list = []
        try:
            for i, xls_data in enumerate(xls_list, 0):
                print i
                # if not xls_data['it_no']['datavalue']:
                #     continue
                new_data_dict = {}
                for db_col, xls_data_dict in xls_data.iteritems():
                    xls_value = xls_data_dict.get('datavalue')
                    # delete unicode _x000D_
                    if xls_value and type(xls_value) in (str, unicode):
                        xls_value = xls_value.replace('_x000D_', '\n')
                    new_data_dict[db_col] = xls_value
                    if db_col in (
                            'dev_fw16_status',
                            'dev_model_status',
                            'dev_ut_status',
                            'dev_it_status',
                            'dev_itn_status',
                    ):
                        xls_value = self.dev_status_dict[
                            xls_value] if xls_value in self.dev_status_dict else None
                    new_data_dict[db_col] = xls_value
                    if db_col in (
                            'dev_status',
                            'ut_status1',
                            'ut_status2',
                            'ut_status3',
                            'ut_status4',
                            'ut_status5',
                            'ut_status6',
                            'ut_status7',
                            'ut_status8',
                            'ut_status9',
                            'ut_status10',
                    ):
                        xls_value = self.dev_status_dict2[
                            xls_value] if xls_value in self.dev_status_dict2 else None
                    new_data_dict[db_col] = xls_value
                # new_data_dict['file_name'] = file_name
                # new_data_dict['it_key'] = ', '.join([file_name, new_data_dict['req_id']])
                curr_commit_list = self._common_add(self._pg, new_data_dict,
                                                    update_time, update_cols)
                if curr_commit_list:
                    commit_list += curr_commit_list
            # if commit_list:
            #     log_info = {'user_id': commit_user_id, "commit_list": commit_list}
            #     commit_log = HmiLog()
            #     log_commit_data = commit_list[0].get("data")
            #     log_commit_data["update_time"] = update_time
            #     flag, commit_id = commit_log.add_commit_log2(pg, log_info)
            #     if flag:
            #         result["result"] = "OK"
            # else:
            self._pg.commit()
            result["result"] = "OK"

        except Exception as e:
            print str(e)
            self._pg.conn.rollback()
            result["error"] = "%s%s" % (new_data_dict.get('req_id'), str(e))
        finally:
            return result
 def do_import(self, xls_file_name, commit_user_id, update_time):
     result = {"result": "NG", "error": ''}
     try:
         xls_list = DocXls('HMI_SCREEN_IT', '0.01').load_data(xls_file_name)
     except Exception as e:
         result["error"] = str(e)
         return result
     self._pg.connect()
     commit_list = []
     try:
         for i, xls_data in enumerate(xls_list, 0):
             print i
             if not xls_data['app_name']['datavalue']:
                 continue
             new_data_dict = {}
             update_cols = []
             for db_col, xls_data_dict in xls_data.iteritems():
                 update_cols.append(db_col)
                 xls_value = xls_data_dict.get('datavalue')
                 # delete unicode _x000D_
                 if xls_value and type(xls_value) in (str, unicode):
                     xls_value = xls_value.replace('_x000D_', '\n')
                 new_data_dict[db_col] = xls_value
                 if db_col in ('in_migration_id', ):
                     xls_value = self.dev_status_dict[
                         xls_value] if xls_value in self.dev_status_dict else None
                 new_data_dict[db_col] = xls_value
                 if db_col in ('followup_migration_id', ):
                     xls_value = self.dev_status_dict2[
                         xls_value] if xls_value in self.dev_status_dict2 else None
                 new_data_dict[db_col] = xls_value
             screen_keys = []
             for key in [
                     "app_name", "first_layer", "second_layer",
                     "third_layer", "layer4", "layer5", "screen_id"
             ]:
                 val = new_data_dict.get(key)
                 if val:
                     screen_keys.append(new_data_dict.get(key))
                 else:
                     screen_keys.append('')
             new_data_dict["screen_key"] = ', '.join(screen_keys)
             if new_data_dict.get("delete"):
                 self.delete(self._pg, new_data_dict["screen_key"])
             else:
                 curr_commit_list = self._common_add(
                     self._pg, new_data_dict, update_time, update_cols)
                 if curr_commit_list:
                     commit_list += curr_commit_list
         if commit_list:
             log_info = {
                 'user_id': commit_user_id,
                 "commit_list": commit_list
             }
             commit_log = HmiLog()
             log_commit_data = commit_list[0].get("data")
             log_commit_data["update_time"] = update_time
             flag, commit_id = commit_log.add_commit_log2(
                 self._pg, log_info)
             if flag:
                 self._pg.commit()
                 result["result"] = "OK"
         else:
             result["result"] = "OK"
         # self._pg.commit()
         # result["result"] = "OK"
     except Exception as e:
         print str(e)
         self._pg.conn.rollback()
         result["error"] = "%s%s" % (new_data_dict.get('screen_id'), str(e))
     finally:
         self._pg.close()
         return result
Example #9
0
 def do_import(self, xls_file_name, update_cols, commit_user_id,
               update_time):
     result = {"result": "NG", "error": ''}
     try:
         xls_list = DocXls('HMI_REQ', '0.05').load_data(xls_file_name)
     except Exception as e:
         result["error"] = str(e)
         return result
     self._pg.connect()
     commit_list = []
     try:
         for i, xls_data in enumerate(xls_list, 0):
             print i
             new_data_dict = {}
             for db_col, xls_data_dict in xls_data.iteritems():
                 xls_value = xls_data_dict.get('datavalue')
                 # delete unicode _x000D_
                 if xls_value and type(xls_value) in (str, unicode):
                     xls_value = xls_value.replace('_x000D_', '\n')
                 if db_col in (
                         'apl_progress',
                         'ng_num',
                 ):
                     try:
                         xls_value = str(int(xls_value))
                     except:
                         xls_value = None
                 if db_col in ('dev_status', ):
                     xls_value = self.dev_status_dict[
                         xls_value] if xls_value in self.dev_status_dict else None
                 new_data_dict[db_col] = xls_value
             # ## 去掉空白和\n
             val = new_data_dict.get("it_file_name")
             if val:
                 new_data_dict["it_file_name"] = val.strip()
             # ## APL设计书番号: APL设计书名称有,APL设计书番号无,那么 APL设计书番号 = 结合测试书番号.
             if new_data_dict.get("apl_test_files"):  # APL设计书名称
                 if not new_data_dict.get("apl_test_nos"):
                     new_data_dict["apl_test_nos"] = new_data_dict.get(
                         "it_nos")  # 结合测试书番号
             curr_commit_list = self._common_add(self._pg, new_data_dict,
                                                 update_time, update_cols)
             if curr_commit_list:
                 commit_list += curr_commit_list
         if commit_list:
             log_info = {
                 'user_id': commit_user_id,
                 "commit_list": commit_list
             }
             commit_log = HmiLog()
             log_commit_data = commit_list[0].get("data")
             log_commit_data["update_time"] = update_time
             flag, commit_id = commit_log.add_commit_log2(
                 self._pg, log_info)
             if flag:
                 self._pg.commit()
                 result["result"] = "OK"
         else:
             # self._pg.commit()
             result["result"] = "OK"
     except Exception as e:
         print e
         self._pg.conn.rollback()
         result["error"] = "%s %s" % (new_data_dict.get('hu_id'), str(e))
     finally:
         self._pg.close()
         return result