예제 #1
0
 def __init__(self, args):
     for op, value in args:
         if op == "-d":
             self.func_name = value.lower()
         elif op == "-m":
             self.model_name = value.lower()
         elif op == "-l":
             self.level_name = value.lower()
         elif op == "-c":
             self.all_flag = value.lower()
         elif op == "-s":
             self.sys_name = value.lower()
         elif op == "-t":
             self.tab_name = value.lower()
         elif op == "-v":
             self.view_name = value.lower()
         elif op == "-f":
             self.file_name = value.lower()
     # 全局变量
     self.insert_hist_file = setting.DATA_FILE + 'dw_sm_hist_ext.txt'  # 历史拉链配置表写入文件
     self.meta_excel_name = setting.TEMPLATE_PATH + 'meta/etl_meta_init.xlsx'  # meta模块配置excel文档
     self.sche_excel_name = setting.TEMPLATE_PATH + 'sche/etl_sche_conf.xlsx'  # 调度模块配置表excel文档名
     self.view_excel_name = setting.TEMPLATE_PATH + 'server/etl_serve_view.xlsx'  # 调度模块配置表excel文档名
     self.server_excel_name = setting.TEMPLATE_PATH + 'server/etl_serve_conf.xlsx'  # 卸载分发模块配置表excel文档名
     self.check_excel_name = setting.TEMPLATE_PATH + 'check/etl_check_cols_quality.xlsx'  # 卸载分发模块配置表excel文档名
     self.logger = operate_log.getLogger("/Users/wangdabin1216/git/dw/log/init/init_server.log")
     self.opos = operate_os.Operate_os(self.logger)
     self.db = operate_mysql.Operate_mysql(self.logger)
     self.ilt = init_load_tab.Init_load_tab(self.logger, self.opos, self.db)
     self.itt = init_trans_tab.Init_trans_tab(self.logger, self.opos, self.db)
     self.ihd = init_hist_data.Init_hist_data(self.logger, self.opos)
     self.igp = init_gen_pro.Init_gen_pro(self.logger, self.opos, self.db)
     self.icd = init_cc_data.Init_cc_data(self.logger, self.opos, self.db)
     self.ims = init_meta_struct.Init_meta_struct(self.logger, self.opos)
     self.imd = init_meta_data.Init_meta_data(self.logger, self.opos, self.db)
예제 #2
0
        #调用存储过程
        self.opos.exec_cmd(call_pro_cmd)
    except Exception as err:
        self.logger.error("put或调用cc.pkg_dw_util.pro_sync_cc_data错误:"+str(err.args))
        sys.exit(-1)

  def main(self):
    #检查输入参数个数
    if len(sys.argv)<4:
        infostr = "Usage: %s source_table ext_table is_exec " %sys.argv[0]
        print("输入参数个数有误,请检查.\n"+infostr)
        sys.exit(-1)
    print( "参数个数正确,开始元表结构初始化.详细日志查询init.log ")
    #输入脚本参数  脚本多一个参数  
    src_tab,ext_tab,is_exec =  sys.argv[1:]
    file_name = setting.DATA_FILE+ext_tab.lower()+".txt"
    self.opos.delete_file(file_name)
    self.get_tab_data(src_tab,file_name)
    self.logger.info("执行Main方法成功")
    #选择是否执行
    if int(is_exec) == 1:
        self.init_cc_data(src_tab,ext_tab)
        self.logger.info("调用init_cc_data方法成功")
    else:
        pass
    sys.exit(0)

if __name__ == '__main__':
    logger=operate_log.getLogger("/Users/wangdabin1216/git/dw/log/init/init_cc_data.log")
    icd=Init_cc_data(logger,operate_os.Operate_os(logger),operate_mysql.Operate_mysql(logger))
    icd.main()
예제 #3
0
            self.db.close_mysql()

    def main(self):
        try:
            self.is_valid_arg()
            t_name = sys.argv[1].lower()
            file = '/etl/dw/sql/tdh/' + t_name + '.sql'
            self.logger.info(
                "\n\n\n\n\------------------------------------开始处理生成" +
                t_name + "程序-------------------\n")
            self.is_exsi_tab(t_name)
            self.bak_Pro_Sql(t_name)
            self.gen_Tmp_Tab_Sql(t_name)
            self.gen_pro(t_name)
            self.replace_Pro_file(t_name)
            self.execu_Sql_Indb(file)
            self.logger.info("\n\n------------------------------------成功生成" +
                             t_name + "程序-------------------\n\n\n\n")
        except Exception as err:
            self.logger.error("程序处理异常:" + str(t_name) + "," + str(err.args))
        finally:
            self.db.close_mysql()


if __name__ == '__main__':
    logger = operate_log.getLogger(
        "/Users/wangdabin1216/git/dw/log/init/init_gen_pro.log")
    igp = Init_gen_pro(logger, operate_os.Operate_os(logger),
                       operate_mysql.Operate_mysql(logger))
    igp.main()
예제 #4
0
    return file_name

  def main(self):
    #判断参数
    if len(sys.argv)<5:
        infostr = "Usage: %s excel tab_name del_condition is_exec" %sys.argv[0]
        self.logger.info("输入参数个数有误,请检查.")
        sys.exit(1)
    self.logger.info("参数个数正确,开始元表数据初始化. ")
    #参数赋值
    #数据库文件名称\excel文件名称\sheet页名称\
    excel_name,sheet_name,del_condition,is_exec = sys.argv[1:] 
    self.logger.info("输入参数为 excel_name:"+excel_name+" sheet_name:"+sheet_name+" del_condition:"+del_condition)
    #执行数据初始化
    sql_file=self.init_meta_data(excel_name,sheet_name,del_condition)
    #选择是否执行
    if int(is_exec) == 1:
        re = self.opos.compile_mysql_file(sql_file)
        if re == 1 :
            print("库表创建编译已完成,请检查执行结果.")
        else:
            print("文件编译出现错误.")
    else:
        pass
    sys.exit(0)

if __name__ == '__main__':
    logger=operate_log.getLogger("/Users/wangdabin1216/git/dw/log/init/init_meta_data.log")
    imt=Init_meta_data(logger,operate_os.Operate_os(logger),operate_mysql.Operate_mysql(logger))
    imt.main()