当前位置: 首页>>代码示例>>Python>>正文


Python config.Log类代码示例

本文整理汇总了Python中config.Log的典型用法代码示例。如果您正苦于以下问题:Python Log类的具体用法?Python Log怎么用?Python Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: auto_reload

def auto_reload(mod):
    """
    @brief      reload modules
    @param      mod: the need reload modules
    """
    try:
        module = sys.modules[mod]
    except:
        Log.error(traceback.format_exc())
        return False

    filename = module.__file__
    # .pyc 修改时间不会变
    # 所以就用 .py 的修改时间
    if filename.endswith(".pyc"):
        filename = filename.replace(".pyc", ".py")
    mod_time = os.path.getmtime(filename)
    if not "loadtime" in module.__dict__:
        module.loadtime = 0

    try:
        if mod_time > module.loadtime:
            reload(module)
        else:
            return False
    except:
        Log.error(traceback.format_exc())
        return False

    module.loadtime = mod_time

    echo('[*] load \'%s\' successful.\n' % mod)
    return True
开发者ID:CrackerCat,项目名称:WeixinBot,代码行数:33,代码来源:utils.py

示例2: recover

    def recover(self):
        """
        @brief      Recover from snapshot data.
        @return     Bool: whether operation succeed.
        """
        cm = ConfigManager()
        [self.uuid, self.redirect_uri, self.uin,
        self.sid, self.skey, self.pass_ticket,
        self.synckey, device_id, self.last_login] = cm.get_wechat_config()

        if device_id:
            self.device_id = device_id

        self.base_request = {
            'Uin': int(self.uin),
            'Sid': self.sid,
            'Skey': self.skey,
            'DeviceID': self.device_id,
        }

        # set cookie
        Log.debug('set cookie')
        self.cookie = set_cookie(self.cookie_file)

        return True
开发者ID:CrackerCat,项目名称:WeixinBot,代码行数:25,代码来源:wechat.py

示例3: send_file

    def send_file(self, user_id, file_path):
        """
        @brief      send file
        @param      user_id  String
        @param      file_path  String
        @return     Bool: whether operation succeed
        """
        title = file_path.split('/')[-1]
        data = {
            'appid': Constant.API_WXAPPID,
            'title': title,
            'totallen': '',
            'attachid': '',
            'type': self.wx_conf['APPMSGTYPE_ATTACH'],
            'fileext': title.split('.')[-1],
        }

        response = self.webwxuploadmedia(file_path)
        if response is not None:
            data['totallen'] = response['StartPos']
            data['attachid'] = response['MediaId']
        else:
            Log.error('File upload error')
        
        return self.webwxsendappmsg(user_id, data)
开发者ID:CrackerCat,项目名称:WeixinBot,代码行数:25,代码来源:wechat_apis.py

示例4: upload_method

def upload_method(cron_id, vpn_ip, work_path, exchange, task_type):
    try:
        run_date = datetime.datetime.now().strftime("%Y%m%d")
        # remote check
        remote_check_flag = dir_check(vpn_ip, work_path)
        local_files = get_local_files(task_type, vpn_ip, work_path)
        print local_files
        # local check
        local_check_flag, size = loacal_files_check(local_files)
        if not local_files or not remote_check_flag or not local_check_flag:
            cron_trigger(cron_id, -1, size, run_date)
            return False
        his_cron_id = cron_trigger(cron_id, 0, size, run_date)
        if his_cron_id < 0:
            return False
        file_str = " ".join(local_files)
        cmd = "rsync -avz --progress %s %[email protected]%s:%s" % (file_str, "mycapitaltrade", vpn_ip, work_path)
        print cmd
        tf_out = tempfile.NamedTemporaryFile()
        tf_out_r = open(tf_out.name, "r")
        proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=tf_out)
        while proc.poll() is None:
            multiple_listen_stdout(cron_id, his_cron_id, size, run_date, tf_out_r)
            time.sleep(0.5)
        else:
            multiple_listen_stdout(cron_id, his_cron_id, size, run_date, tf_out_r)
        tf_out_r.close()
        tf_out.close()
        return True
    except:
        Log.error("rsync log failed. %s" % traceback.format_exc())
        return False
开发者ID:colin-zhou,项目名称:reserve,代码行数:32,代码来源:upload_conf.py

示例5: delete_table

 def delete_table(self, table):
     """
     @brief      Delete a table in database
     @param      table  String
     """
     sql = "DROP TABLE if exists %s;" % table
     Log.debug('DB -> %s' % sql)
     self.execute(sql)
开发者ID:CrackerCat,项目名称:WeixinBot,代码行数:8,代码来源:sqlite_db.py

示例6: insert

 def insert(self, table, value):
     """
     @brief      Insert a row in table
     @param      table  String
     @param      value  Tuple
     """
     sql = ("INSERT INTO %s VALUES (" + ",".join(['?'] * len(value)) + ");") % table
     Log.debug('DB -> %s' % sql)
     self.execute(sql, value)
开发者ID:CrackerCat,项目名称:WeixinBot,代码行数:9,代码来源:sqlite_db.py

示例7: create_db

 def create_db(self, db_name):
     """
     @brief      Creates a database
     @param      db_name  String
     """
     if self.conf['database'] not in self.show_database():
         sql = 'CREATE DATABASE IF NOT EXISTS %s CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci' % db_name
         Log.debug('DB -> %s' % sql)
         self.execute(sql)
开发者ID:CrackerCat,项目名称:WeixinBot,代码行数:9,代码来源:mysql_db.py

示例8: close

    def close(self):
        """
        @brief      close connection to database
        """
        Log.debug('DB -> close')
        # 关闭数据库连接
        self.conn.close()

        
开发者ID:CrackerCat,项目名称:WeixinBot,代码行数:7,代码来源:mysql_db.py

示例9: create_table

 def create_table(self, table, cols):
     """
     @brief      Creates a table in database
     @param      table  String
     @param      cols   String, the cols in table
     """
     sql = "CREATE TABLE if not exists %s (%s);" % (table, cols)
     Log.debug('DB -> %s' % sql)
     self.execute(sql)
开发者ID:CrackerCat,项目名称:WeixinBot,代码行数:9,代码来源:sqlite_db.py

示例10: delete_table

 def delete_table(self, table):
     """
     @brief      Delete a table in database
     @param      table  String
     """
     if table in self.table_cols:
         sql = "DROP TABLE IF EXISTS %s" % table
         Log.debug('DB -> %s' % sql)
         self.execute(sql)
         self.table_cols.pop(table)
开发者ID:CrackerCat,项目名称:WeixinBot,代码行数:10,代码来源:mysql_db.py

示例11: delete

 def delete(self, table, field='', condition=''):
     """
     @brief      execute sql commands, return result if it has
     @param      table  String
     @param      field  String
     @param      condition  String
     """
     sql = "DELETE FROM %s WHERE %s=%s" % (table, field, condition)
     Log.debug('DB -> %s' % sql)
     self.execute(sql)
开发者ID:CrackerCat,项目名称:WeixinBot,代码行数:10,代码来源:mysql_db.py

示例12: insert

 def insert(self, table, value):
     """
     @brief      Insert a row in table
     @param      table  String
     @param      value  Tuple
     """
     col_name = self.table_cols[table][1:]
     sql = "INSERT INTO %s(%s) VALUES (%s)" % (table, str(','.join(col_name)), array_join(value, ','))
     Log.debug('DB -> %s' % sql)
     self.execute(sql)
开发者ID:CrackerCat,项目名称:WeixinBot,代码行数:10,代码来源:mysql_db.py

示例13: insertmany

 def insertmany(self, table, values):
     """
     @brief      Insert many rows in table
     @param      table  String
     @param      values  Array of tuple
     """
     col_name = self.table_cols[table][1:]
     sql = 'INSERT INTO %s(%s) VALUES (%s)' % (table, ','.join(col_name), ','.join(['%s'] * len(values[0])))
     Log.debug('DB -> %s' % sql)
     self.execute(sql, values)
开发者ID:CrackerCat,项目名称:WeixinBot,代码行数:10,代码来源:mysql_db.py

示例14: loacal_files_check

def loacal_files_check(files):
    if not files:
        return False, 0
    try:
        total_size = 0
        for tfile in files:
            total_size += os.path.getsize(tfile)
        return True, total_size
    except os.error:
        Log.error("files %s not exist or can't access" % files)
        return False, 0
开发者ID:colin-zhou,项目名称:reserve,代码行数:11,代码来源:upload_conf.py

示例15: get_config_strategy

def get_config_strategy(file_content):
    ret_list = []
    try:
        config_obj = xmltodict.parse(file_content)
        st_obj = config_obj["MyExchange"]["strategies"]["strategy"]
        if not isinstance(st_obj, list):
            st_obj = [st_obj]
        for st in st_obj:
            ret_list.append(st["@model_file"])
    except Exception, ex:
        Log.error("xml parse error! %s" % ex)
开发者ID:colin-zhou,项目名称:reserve,代码行数:11,代码来源:upload_conf.py


注:本文中的config.Log类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。