def test_check_with_missing_yaml_terminator(): header = """ --- layout: workshop root: . <!-- Edit the values in the block above to be appropriate for your workshop. Run 'tools/check' *before* committing to make sure that changes are good. --> """ assert check.check_file('test.html', header) != []
def test_check_without_enddate(): header = """--- layout: workshop root: . venue: Euphoric State University address: 123 College Street, Euphoria country: United-States humandate: Feb 17-18, 2020 humantime: 9:00 am - 4:30 pm startdate: 2020-06-17 latlng: 41.7901128,-87.6007318 instructor: ["Grace Hopper", "Alan Turing"] contact: [email protected] helper: [ "John von Neumann" ] ---""" assert check.check_file('test.html', header) == []
def main(): parser = argparse.ArgumentParser() parser.add_argument("-l", "--path_to_links", dest="links_path", help="text file having list of download links", type=str, required=True) parser.add_argument("-d", "--destination", dest="download_directory", help="download location of files", type=str, required=True) parser.add_argument("-u", "--username", dest="username", help="username for website", type=str, required=True) parser.add_argument("-p", "--password", dest="password", help="password for website", type=str, required=True) parser.add_argument("-n", "--threads", dest="thread_count", help="amount of threads for download", type=int, required=True) args = parser.parse_args() file = check.check_file(args.links_path) directory = check.check_dir(args.download_directory) start = time.time() ThreadedFunction.RunMethodWithThreads( LinkDownload.link_download, (file, directory, args.username, args.password), args.thread_count) end = time.time() elapsed_time = end - start print("\n -- Total Download Time: %d:%.2d --\n" % (elapsed_time / 60, elapsed_time % 60)) return 0
def test_check_with_enddate(): header_sample = """--- layout: workshop root: . venue: Euphoric State University address: 123 College Street, Euphoria country: United-States humandate: Feb 17-18, 2020 humantime: 9:00 am - 4:30 pm startdate: 2020-06-17 enddate: 2020-06-18 latlng: 41.7901128,-87.6007318 instructor: ["Grace Hopper", "Alan Turing"] helper: [ ] contact: [email protected] ---""" assert check.check_file(make_file(header_sample))
def __get_pdb_box(pdb_file_path): """ 计算蛋白或者配体的空间中心坐标和最大立方体长宽高。 :param pdb_file_path: pdb或者pdbqt文件路径名 :return: 中心x坐标,中心y坐标,中心z坐标,长,宽,高。 """ # 保证文件存在 if not check.check_file(pdb_file_path): print(pdb_file_path + "不存在") sys.exit() atoms_x_list = [] atoms_y_list = [] atoms_z_list = [] # 额外距离 extra_distance = 0 # 读取所有非H原子的坐标 with open(pdb_file_path, encoding='UTF-8') as f: lines = f.readlines() for line in lines: if line.startswith("ATOM") or line.startswith("HETATM"): if line[13:14] != "H": atoms_x_list.append(float(line[30:38])) atoms_y_list.append(float(line[38:46])) atoms_z_list.append(float(line[46:54])) if len(atoms_x_list) == 0: print("没有检测到原子") sys.exit() box_center_x = round(sum(atoms_x_list) / len(atoms_x_list), 3) box_center_y = round(sum(atoms_y_list) / len(atoms_y_list), 3) box_center_z = round(sum(atoms_z_list) / len(atoms_z_list), 3) box_length = round(max(atoms_x_list) - min(atoms_x_list), 1) + extra_distance box_width = round(max(atoms_y_list) - min(atoms_y_list), 1) + extra_distance box_height = round(max(atoms_z_list) - min(atoms_z_list), 1) + extra_distance return box_center_x, box_center_y, box_center_z, box_length, box_width, box_height
def test_check_with_leading_blank_lines(): header = """ --- layout: workshop root: . venue: Euphoric State University address: 123 College Street, Euphoria country: United-States humandate: Feb 17-18, 2020 humantime: 9:00 am - 4:30 pm startdate: 2020-06-17 enddate: 2020-06-18 latlng: 41.7901128,-87.6007318 instructor: ["Grace Hopper", "Alan Turing"] helper: [ ] contact: [email protected] eventbrite: # FIXME ---""" assert check.check_file('test.html', header) != []
def upload_file(): global prev files = request.files.getlist('files[]') WL1 = request.form.get("WL1") WL2 = request.form.get("WL2") for file in files: if file: if allowed_file(file.filename): filename = time.strftime("%Y%m%d-%H%M%S") filename += "_unprocessed_" + "WL1_" + WL1 + "_WL2_" + WL2 + ".csv" file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) if not check_file(filename): flash("Improper format") os.remove( os.path.join(app.config['UPLOAD_FOLDER'], filename)) else: update_file(filename) else: flash('File extension not supported!') prev = filename return redirect('/')
#!/usr/bin/python3 from check import check_file from utils import * cdname = os.path.dirname(__file__) archive_folder = os.path.join(cdname, 'archive', '201711') if __name__ == '__main__': for root, dirs, files in os.walk(archive_folder): for file in sorted(files): check_file(os.path.join(root, file))
#!/usr/bin/python3 import os from check import check_file, max_missed_pid from utils import my_log cdname = os.path.dirname(__file__) archive_dir = os.path.join(cdname, 'archive', '201810') if __name__ == '__main__': last_pid = None for root, dirs, files in os.walk(archive_dir): for file in sorted(files): filename = os.path.join(root, file) oldest_pid, newest_pid = check_file(filename) # Check missed posts between files if oldest_pid: if (last_pid and oldest_pid > last_pid + 1 and oldest_pid < last_pid + max_missed_pid): for i in range(last_pid + 1, oldest_pid): my_log('{} {} MISSED BETWEEN FILES'.format(i, file)) last_pid = oldest_pid