Ejemplo n.º 1
0
def add_loss(value):
    if not path.isdir(config.log_dir):
        os.mkdir(config.log_dir)
        add_log("create folder '{}'".format(config.log_dir))
    loss_file = path.join(config.log_dir, config.loss_name)
    tools.write_file(loss_file, value, False)
    return
Ejemplo n.º 2
0
def main():
    # 用记事本打开文件后,会在conf文本头前面加上\ufeff,需要处理掉
    content = tools.read_file('config.conf')
    tools.write_file('config.conf', content.replace('\ufeff', ''))

    # 读配置
    cp = configparser.ConfigParser(allow_no_value = True)
    with codecs.open('config.conf', 'r', encoding='utf-8') as f:
        cp.read_file(f)

    sections = cp.sections()
    for section in sections:
        remote_url = cp.get(section, 'remote_url')
        local_save_path = cp.get(section, 'local_save_path')
        project_path = cp.get(section, 'project_path')
        main_lnk_paths = cp.get(section, 'main_lnk_paths').split(',')
        sync_files = cp.get(section, 'sync_files').split(',')
        ignore_files = cp.get(section, 'ignore_files').split(',')

        # # 调用
        update_code = UpdateCode(remote_url, local_save_path, project_path, main_lnk_paths, sync_files, ignore_files)
        if update_code.check_remote_tag():
            update_code.download_code()
            update_code.copy_file()
            update_code.close_process()
            update_code.start_process()
Ejemplo n.º 3
0
def add_log(content):
    if not path.isdir(config.log_dir):
        os.mkdir(config.log_dir)
        add_log("message:create folder '{}'".format(config.log_dir))
    log_file = path.join(config.log_dir, config.log_name)
    print(content)
    tools.write_file(log_file, content, True)
    return
Ejemplo n.º 4
0
    def _save_current_id(self):
        '''
        @summary: 保存做到的id, 下次接着做
        ---------
        ---------
        @result:
        '''

        tools.write_file(STO_CURRENT_ID_FILE, str(self._current_csr_res_id))
Ejemplo n.º 5
0
def get_url(time_lenght = 60):
    '''
    @summary:
    ---------
    @param time_lenght: 时间段 分钟
    ---------
    @result:
    '''

    current_date = tools.get_current_date()
    per_date = tools.read_file(STO_PER_SYNC_TIME) or tools.timestamp_to_date(tools.get_current_timestamp() - time_lenght * 60)

    tools.write_file(STO_PER_SYNC_TIME, current_date)

    root_url = 'http://192.168.60.38:8001/hotspot_al/interface/getCluesDataSearchInfo?pageNo=%d&pageSize=100&updateSTime={per_date}&updateETime={current_date}&sort=5&isDesc=0'.format(per_date = per_date, current_date = current_date)
    return root_url
Ejemplo n.º 6
0
def main():
    db = OracleDB()
    sql = 'select t.id clues_id,to_char(t.keyword1),to_char(t.keyword2),to_char(t.keyword3),t.zero_id  from TAB_IOPM_CLUES t'
    results = db.find(sql)

    clues_json = {
        "message":
        "查询成功",
        "status":
        1,
        "data": [{
            "clues_id": 104,
            "keyword1": "",
            "keyword2": "",
            "keyword3": "",
            "zero_id": 2
        }]
    }

    clues_json['data'] = []

    for result in results:
        data = {
            "clues_id":
            result[0] if result[0] else "",
            "keyword1":
            "%s" %
            (result[1].replace('"', '“').replace('、', '')[:-1] if result[1][-1]
             == ',' else result[1].replace('"', '')) if result[1] else "",
            "keyword2":
            "%s" %
            (result[2].replace('"', '“').replace('、', '')[:-1] if result[2][-1]
             == ',' else result[2].replace('"', '')) if result[2] else "",
            "keyword3":
            "%s" %
            (result[3].replace('"', '“').replace('、', '')[:-1] if result[3][-1]
             == ',' else result[3].replace('"', '')) if result[3] else "",
            "zero_id":
            result[4] if result[4] else ""
        }
        clues_json["data"].append(data)

    clues_json = tools.dumps_json(clues_json)
    print(clues_json)

    tools.write_file('./clues.txt', clues_json)
Ejemplo n.º 7
0
 def close(self):
     tools.write_file(STO_MAX_ID_FILE, str(self._max_id))
Ejemplo n.º 8
0
 def record_now_record_time(self, record_time):
     self._record_time[self._per_record_time_key] = record_time
     tools.write_file(SYNC_TIME_FILE, tools.dumps_json(self._record_time))
Ejemplo n.º 9
0
def save_clues_to_file(clues_json_str):
    tools.write_file('clues/clues.txt', clues_json_str)
    os.system('start clues\\')
Ejemplo n.º 10
0
 def record_now_record_time(self, record_time):
     self._record_time[self._per_record_time_key] = record_time
     tools.write_file(self._sync_time_file,
                      tools.dumps_json(self._record_time))
Ejemplo n.º 11
0
 def _record_now_record_time(self, record_time):
     self._record_time['news_record_time'] = record_time
     tools.write_file(SYNC_TIME_FILE, tools.dumps_json(self._record_time))
Ejemplo n.º 12
0
 def __record_current_tag(self, current_tag):
     self._tag_json[self._project_name] = current_tag
     tools.write_file(VERSION_FILE, tools.dumps_json(self._tag_json))