Esempio n. 1
0
def make_test_with_loc(results_root, target_loc):

    second_loc_code = target_loc
    first_loc_code = get_reference_loc(second_loc_code)

    pathes = dict()

    print '{} <- {}'.format(first_loc_code, second_loc_code)
    start = time.time()
    path_to_old_loc, path_to_new_loc = xml_reader.get_pathes()
    first_old_loc = os.path.join(path_to_old_loc, first_loc_code, 'text')
    first_new_loc = os.path.join(path_to_new_loc, first_loc_code, 'text')
    second_old_loc = os.path.join(path_to_old_loc, second_loc_code, 'text')
    second_new_loc = os.path.join(path_to_new_loc, second_loc_code, 'text')
    root, first_diff, second_diff, second_mo_test, mo_origin, mo_created = get_output_pathes(results_root,
                                                                                             first_loc_code,
                                                                                             second_loc_code)
    pathes['results_root'] = results_root
    pathes['path_to_old_loc'] = path_to_old_loc
    pathes['path_to_new_loc'] = path_to_new_loc
    pathes['first_loc_code'] = first_loc_code
    pathes['second_loc_code'] = second_loc_code
    pathes['first_old_loc'] = first_old_loc
    pathes['first_new_loc'] = first_new_loc
    pathes['second_old_loc'] = second_old_loc
    pathes['second_new_loc'] = second_new_loc
    pathes['root'] = root
    pathes['first_diff'] = first_diff
    pathes['second_diff'] = second_diff
    pathes['second_mo_test'] = second_mo_test
    pathes['mo_origin'] = mo_origin
    pathes['mo_created'] = mo_created

    loc_pathes = [first_old_loc, first_new_loc, second_old_loc, second_new_loc]
    for loc in loc_pathes:
        if not is_folder_exist(loc):
            print "Path {} doesn't exist. Please check you localizations and try again.\n".format(loc)
            exit()
    create_folders(pathes)
    check_rus_symbols = True if second_loc_code not in ['BG', 'BE', 'UK', 'KK', 'RU'] else False
    print 'Find rus symbols in target localization? {}'.format(check_rus_symbols)
    print 'Doing tests...'
    critical, warnings, bugs = make_version_test(pathes, check_rus_symbols)
    write_bugs_into_file(pathes['root'], '{}_bugs.txt'.format(pathes['second_loc_code']), bugs)
    write_bugs_into_file(pathes['root'], '{}_critical.txt'.format(pathes['second_loc_code']), critical)
    write_bugs_into_file(pathes['root'], '{}_warnings.txt'.format(pathes['second_loc_code']), warnings)
    print 'Creating mo files...'
    mo_copy(pathes['second_new_loc'] + '\LC_MESSAGES', pathes['mo_origin'])
    make_mo(pathes['second_new_loc'], pathes['mo_created'])
    print 'Checking if mo files are relevant...'
    check_mo_relevance(pathes['mo_origin'], pathes['mo_created'])
    # print 'Opening diffs in beyond compare'
    # open_beyond_compare(pathes['first_diff'], pathes['second_diff'])
    print 'Tests finished.'
    print 'Spent time: {} sec'.format(int(time.time() - start))
    print 'Making html files'
    make_html.make_html(pathes['root'])
    cleaner_empty_po(pathes['first_diff'])
    cleaner_empty_po(pathes['second_diff'])
Esempio n. 2
0
def index():
    if request.method == 'GET':
        return render_template('index.html')
    if request.method == 'POST':
        count = request.form['count']
        query = request.form['query']
        #if int(count) == 1:
        #	username = request.form['name']
        #	if username == "" or username == "Album search (Leave blank for random album.)":
        #		data = readJson()
        #		username = choice(data)
        #		storeVar(username)
        #	else:
        #		pass
        #else:
        #	if os.path.exists('userdata.p'):
        #		username = loadVar()
        #	else:
        #		username = request.form['name']

        #print username
        #if int(count) == 7:
        #	removePickle()

        return make_html(query, int(count))
Esempio n. 3
0
def index():
	if request.method == 'GET':
		return render_template('index.html')
	if request.method == 'POST':
		count = request.form['count']
		query = request.form['query']
		#if int(count) == 1:
		#	username = request.form['name']
		#	if username == "" or username == "Album search (Leave blank for random album.)":
		#		data = readJson()
		#		username = choice(data)
		#		storeVar(username)
		#	else:
		#		pass
		#else:
		#	if os.path.exists('userdata.p'):
		#		username = loadVar()
		#	else:
		#		username = request.form['name']
		
		#print username
		#if int(count) == 7:
		#	removePickle()

		return make_html(query, int(count))
Esempio n. 4
0
def show_and_save(stream, target, predict, save_path_f, save_path_d,
                  save_path_o):
    batch = 0
    t_r = np.exp(target)
    y_r = np.exp(predict)
    for it in stream.get_epoch_iterator():
        e_l = target[batch] - predict[batch]
        e_r = t_r[batch] - y_r[batch]
        for i in range(len(it[0])):
            img = it[0][i]
            dis_img = utility.change_aspect_ratio(img, t_r[batch][i], 1)
            fix_img = utility.change_aspect_ratio(dis_img, 1 / y_r[batch][i],
                                                  1)

            print '[test_data]:', i + 1
            print '[t_l]:', round(target[batch][i],
                                  4), '\t[t_r]:', round(t_r[batch][i], 4)
            print '[y_l]:', round(predict[batch][i],
                                  4), '\t[y_r]:', round(y_r[batch][i], 4)
            print '[e_l]:', round(e_l[i], 4), '\t[e_r]:', round(e_r[i], 4)

            plt.figure(figsize=(16, 16))
            plt.subplot(131)
            plt.title('Distorted image')
            plt.tick_params(labelbottom='off',
                            labeltop='off',
                            labelleft='off',
                            labelright='off')
            plt.tick_params(bottom='off', top='off', left='off', right='off')
            plt.imshow(dis_img)
            plt.subplot(132)
            plt.title('Fixed image')
            plt.tick_params(labelbottom='off',
                            labeltop='off',
                            labelleft='off',
                            labelright='off')
            plt.tick_params(bottom='off', top='off', left='off', right='off')
            plt.imshow(fix_img)
            plt.subplot(133)
            plt.title('Normal image')
            plt.tick_params(labelbottom='off',
                            labeltop='off',
                            labelleft='off',
                            labelright='off')
            plt.tick_params(bottom='off', top='off', left='off', right='off')
            plt.imshow(img)
            plt.show()

            utility.save_image(dis_img, save_path_d, ('%.18f' % e_l[i]))
            utility.save_image(fix_img, save_path_f, ('%.18f' % e_l[i]))
            utility.save_image(img, save_path_o, ('%.18f' % e_l[i]))

        batch += 1
    make_html.make_html(save_path_d)
    make_html.make_html(save_path_f)
    make_html.make_html(save_path_o)
Esempio n. 5
0
def send(request):
    try:
        raw_data = dict(request.POST)
        data = pd.read_json(raw_data["data"][0])
        sheet_name = raw_data["sheet_name"][0]
        scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
        credentials = ServiceAccountCredentials.from_json_keyfile_name(gspread_auth.jsonkey_path, scope)
        gc = gspread.authorize(credentials)
        worksheet = gc.open_by_url(gspread_auth.gspread_url).worksheet(sheet_name)
        # set_with_dataframe(worksheet, data, include_index=True)
        
        
    except Exception as e:
        import traceback
        traceback.print_exc()
        return HttpResponseServerError()
    return HttpResponse(make_html("Succeed!"))
    file_name_html = file_name.rstrip(".md")
    file_name_html = file_name_html + ".html"
    exists_output_file(file_name_html)
    dest_file = open(file_name_html, "w+")
    return dest_file

    
if __name__ == '__main__':
    if (sys.argv[0] == sys.argv[-1]):
        print("Please add a file to compile")
        exit(1)

    file_name, source_file, flags = checks.check_all(sys.argv)

    dest_file = make_output_file_html(file_name)
    standard_head_text = output_file_html_standard_head_text(file_name)
    dest_file.write(standard_head_text)

    track_node = keep_track_of_nodes.Keep_track_of_nodes()
    start_node = nodes.Node("root", [source_file.read()])
    track_node.set_start_node(start_node)

    node_tree = make_nodes.analyse_source(source_file, track_node)
    html = make_html.make_html(track_node)
    #  html = 'html'
    dest_file.write(html)
    
    standard_bottom_text = output_file_html_standard_bottom_text()
    dest_file.write(standard_bottom_text)
    start_node.visualize_node_stream()
Esempio n. 7
0
        if os.path.exists(html_file):
            md_mtime = os.stat(md_file).st_mtime
            html_mtime = os.stat(html_file).st_mtime
            if md_mtime > html_mtime:
                should_make_html = True
        else:
            should_make_html = True

        if should_make_html:
            print '%s' % md_file
            print '  -> %s' % html_file

            depth_count = root.count(os.path.sep) - config.md_dir.count(os.path.sep)
            depth_str = os.path.sep.join(['..'] * depth_count)

            html = make_html.make_html(open(md_file, 'r').read(), os.path.join(depth_str, 'style.css'))
            open(html_file, 'w').write(html)

        rel_path = html_file
        if rel_path.startswith(config.html_dir):
            rel_path = rel_path[len(config.html_dir):]
        links.append(rel_path.strip(os.path.sep))

index_path = os.path.join(config.html_dir, 'index.html')
print 'writing %s' % index_path
index_file = open(index_path, 'w')
index_file.write('<html><head>')
index_file.write('<title>%s</title>' % config.title)
index_file.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />')
index_file.write('</head>')
index_file.write('<body>')
Esempio n. 8
0
def make_pdf(file):
    htmltext = make_html(file)
    with open(file.replace(".fit", ".html"), "w") as f:
        f.write(htmltext)
    pdfkit.from_file(file.replace(".fit", ".html"),
                     file.replace(".fit", ".pdf"))
Esempio n. 9
0
            continue
        md_file = os.path.join(root, file_name)
        html_file = os.path.join(root, file_name[:-3] + '.html')
        should_make_html = False
        if os.path.exists(html_file):
            md_mtime = os.stat(md_file).st_mtime
            html_mtime = os.stat(html_file).st_mtime
            if md_mtime > html_mtime:
                should_make_html = True
        else:
            should_make_html = True

        if should_make_html:
            print '%s' % md_file
            print '  -> %s' % html_file
            html = make_html.make_html(open(md_file, 'r').read(), 'style.css')
            open(html_file, 'w').write(html)

        rel_path = html_file
        if rel_path.startswith(config.html_dir):
            rel_path = rel_path[len(config.html_dir):]
        links.append(rel_path.strip(os.path.sep))

index_path = os.path.join(config.html_dir, 'index.html')
print 'writing %s' % index_path
index_file = open(index_path, 'w')
index_file.write('<html><head>')
index_file.write('<title>%s</title>' % config.title)
index_file.write(
    '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />')
index_file.write('</head>')
Esempio n. 10
0
            continue
        md_file = os.path.join(root, file_name)
        html_file = os.path.join(root, file_name[:-3] + '.html')
        should_make_html = False
        if os.path.exists(html_file):
            md_mtime = os.stat(md_file).st_mtime
            html_mtime = os.stat(html_file).st_mtime
            if md_mtime > html_mtime:
                should_make_html = True
        else:
            should_make_html = True

        if should_make_html:
            print '%s' % md_file
            print '  -> %s' % html_file
            html = make_html.make_html(open(md_file, 'r').read(), 'style.css')
            open(html_file, 'w').write(html)

        rel_path = html_file
        if rel_path.startswith(config.html_dir):
            rel_path = rel_path[len(config.html_dir):]
        links.append(rel_path.strip(os.path.sep))

index_path = os.path.join(config.html_dir, 'index.html')
print 'writing %s' % index_path
index_file = open(index_path, 'w')
index_file.write('<html><head>')
index_file.write('<title>%s</title>' % config.title)
index_file.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />')
index_file.write('</head>')
index_file.write('<body>')