コード例 #1
0
def process_multiple(log, do_fetch=True, do_parse=True, do_merge=True):
    root = config["data-dir"]

    if do_fetch:
        tokens = Tokens()
        api = API(tokens, log)
        util.delete_files(root + '/processing/invoices', '*.json')
        success, invoice_cnt = api.fetch_invoice_details(hours_delta=30,
                                                         tz_offset=7)
        if success and invoice_cnt > 0:
            log.write(
                "INFO api invoices extraction succeeded {:,} invoices saved to : {}"
                .format(invoice_cnt, '/processing/invoices'))
        elif success and invoice_cnt == 0:
            log.write(
                "INFO api no invoices extracted (no new/updated invoices in refresh period)"
            )
            return True
        else:
            log.write(
                "ERROR api invoices extraction failed {:,} invoices saved to : {}"
                .format(invoice_cnt, '/processing/invoices'))
            return False

    if do_parse:
        util.delete_files(root + '/processing/invoices', '*.csv')
        parser = Parser(log)
        parser.parse('invoices-line-items')

    if do_merge:
        merger = Merger(log)
        merger.merge_invoice_delta()

    return True
コード例 #2
0
def process_single(log, do_fetch=True, do_parse=True):
    root = config["data-dir"]

    if do_fetch:
        tokens = Tokens()
        api = API(tokens, log)
        util.delete_files(root + '/processing/default', '*.json')
        if not api.fetch_data("items"):
            return False
        if not api.fetch_data("branding-themes"):
            return False
        if not api.fetch_data("contacts"):
            return False
        if not api.fetch_data("invoices"):
            return False

    if do_parse:
        util.delete_files(root + '/processing/default', '*.csv')
        parser = Parser(log)
        parser.parse('branding-themes')
        parser.parse('items')
        parser.parse('contacts')
        parser.parse('invoices')

    return True
コード例 #3
0
ファイル: raxml.py プロジェクト: wangzhennan14/HomBlocks
def remove_files(aln_path, model):
    '''remove all files from the alignment directory that are produced by raxml'''
    dir, file = os.path.split(aln_path)
    analysis_ID = raxml_analysis_ID(aln_path, model)
    dir = os.path.abspath(dir)
    fs = os.listdir(dir)
    fnames = fnmatch.filter(fs, '*%s*' % analysis_ID)
    util.delete_files(fnames)
コード例 #4
0
def remove_files(aln_path, model):
    '''remove all files from the alignment directory that are produced by raxml'''
    dir, file = os.path.split(aln_path)
    analysis_ID = raxml_analysis_ID(aln_path, model)
    dir = os.path.abspath(dir)
    fs = os.listdir(dir)
    fnames = fnmatch.filter(fs, '*%s*' % analysis_ID)
    util.delete_files(fnames)
コード例 #5
0
ファイル: raxml.py プロジェクト: alephreish/partitionfinder
def remove_files(aln_path, model):
    '''remove all files from the alignment directory that are produced by raxml'''
    dir, file = os.path.split(aln_path)
    analysis_ID = raxml_analysis_ID(aln_path, model)
    dir = os.path.abspath(dir)
    fs = os.listdir(dir)
    fnames = fnmatch.filter(fs, '*%s*%s*' % ("RAxML", analysis_ID))

    pths = [os.path.join(dir, p) for p in fnames]
    util.delete_files(pths)
コード例 #6
0
def remove_files(aln_path, model):
    '''remove all files from the alignment directory that are produced by raxml'''
    dir, file = os.path.split(aln_path)
    analysis_ID = raxml_analysis_ID(aln_path, model)
    dir = os.path.abspath(dir)
    fs = os.listdir(dir)
    fnames = fnmatch.filter(fs, '*%s*%s*' % ("RAxML", analysis_ID))

    pths = [os.path.join(dir, p) for p in fnames]
    util.delete_files(pths)
コード例 #7
0
def just_upload_file():
    if request.method == 'POST':
        # delete previous files
        delete_files(app.config['UPLOAD_FOLDER'])
        # delete_files(app.config['SAVE_FOLDER_segmentation'])
        delete_files(app.config['SAVE_FOLDER_detection'])

        file = request.files['file']
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            print "---upload", file.filename
            # set GLOBAL_FILE_NAME
            app.config['GLOBAL_FILE_NAME'] = filename
            # save a copy to UPLOAD_FOLDER
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            # create dzifile
            dzipath = createdz(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            # if path != '', then exec editPaperSeg.js
            return render_template("entry.html", path = dzipath)
    return render_template("entry.html", path = '')
コード例 #8
0
def remove_files(aln_path, model):
    '''remove all files from the alignment directory that are produced by phyml'''
    fnames = make_output_path(aln_path, model)
    util.delete_files(fnames)
コード例 #9
0
def img_process_lab():
    if request.method == 'GET':
        messages = []
        types = ImgType.objects.exclude('id')
        for each in types:
            sub_types = ImgOperation.objects(type__name=each.name).exclude(
                'id', 'type')
            messages.append({'type': each.name, 'subType': list(sub_types)})

        return jsonify({'result': 1, 'message': messages})
    else:
        request_body = json.loads(request.get_data())
        operation = request_body['operations'][0]

        o_code = operation['code']
        o_params = operation['params']
        image_base64 = request_body['image']
        try:
            img_name = base64_to_img_file(image_base64)
        except IOError as e:
            app.logger.exception(e)
            return jsonify({'result': 0, 'message': '图片传送失败,请再试一次或换张图'})

        img_log = None
        img_arr = cv2.imread(os.path.join(get_root_path(), img_name),
                             cv2.IMREAD_COLOR)

        if img_arr is None:
            return jsonify({'result': 0, 'message': '服务器空间不足,请联系QQ:644306737'})

        try:
            if int(o_code) < 200:
                processed_img_arr = smooth_manager.process(
                    o_code, o_params, img_arr)
            elif int(o_code) < 300:
                thresh, processed_img_arr = segmentation_manager.process(
                    o_code, o_params, img_arr)
                img_log = dict({'str': '最佳阈值为{}'.format(thresh)})
            elif int(o_code) < 400:
                processed_img_arr = contour_manager.process(
                    o_code, o_params, img_arr)
            elif int(o_code) < 500:
                processed_img_arr = corner_manager.process(
                    o_code, o_params, img_arr)
            elif int(o_code) < 600:
                processed_img_arr = morphology_manager.process(
                    o_code, o_params, img_arr)
            else:
                return jsonify({'result': 0, 'message': '哎呀~该方法尚未完成,请静候佳音'})
        except Exception as e:
            app.logger.exception(e)
            return jsonify({
                'result':
                0,
                'message':
                '处理失败:{},请联系QQ:644306737'.format(e.message)
            })

        try:
            processed_img_name = img_arr_to_img_file(img_name, o_code,
                                                     processed_img_arr)
        except IOError as e:
            app.logger.exception(e)
            return jsonify({'result': 0, 'message': '服务器空间不足,请联系QQ:644306737'})

        try:
            base64_data = img_file_to_base64(processed_img_name)
        except Exception as e:
            app.logger.exception(e)
            return jsonify({
                'result': 0,
                'message': '图片转换传输失败,请再试一次,或联系QQ:644306737'
            })

        if img_log is None:
            message = dict({'image': base64_data})
        else:
            message = dict({'image': base64_data, 'log': img_log})

        delete_files([img_name, processed_img_name])
        return jsonify({'result': 1, 'message': message})
コード例 #10
0
ファイル: phyml.py プロジェクト: wrightaprilm/partitionfinder
def remove_files(aln_path, model):
    '''remove all files from the alignment directory that are produced by phyml'''
    fnames = make_output_path(aln_path, model)
    util.delete_files(fnames)