示例#1
0
文件: utils.py 项目: Shekcon/Intek
def get_files_direc(direc='.', mode=''):
    '''
    Task: return list file in subdirectory passed and directory passed
    '''
    dir_direc = [direc]
    file_direc = []
    # find all path of file in src
    while dir_direc:
        # take directory from src
        try:
            direc = dir_direc.pop()
            entry_direc = os.scandir(direc)
            for e in entry_direc:
                # store file in data_dir
                if e.is_file():
                    file_direc.append(rm_head_lgit(os.path.abspath(e.path)))
                # store directory in data_dir
                if e.is_dir() and ".lgit" not in e.path:
                    dir_direc.append(e.path)
        except PermissionError:
            if mode == 'add':
                print("warning: could not open directory '%s/%s/': "
                      "Permission denied " % (os.getcwd(), direc))
                exit_program()
    return file_direc
示例#2
0
def handle_subshell(command):
    try:
        pid = os.fork()
    except OSError:
        pass
    if pid == 0:
        handle_logic_op(command[0][1:-1])
        exit_program(int(os.environ['?']))
    exit_code = os.wait()[1]
    os.environ['?'] = str(exit_code)
示例#3
0
def builtins_exit(exit_code='0'):  # implement exit
    Shell.save_history()
    Shell.printf('exit')
    exit_value = 0
    if exit_code:
        if exit_code.isdigit():
            exit_value = int(exit_code)
        else:
            Shell.printf('intek-sh: exit: ' + exit_code)
    curses.endwin()
    exit_program(exit_value)
示例#4
0
def create_structure_lgit(direcs, files):
    if not os.path.exists('.lgit'):
        os.makedirs('.lgit')
    elif os.path.isfile('.lgit'):
        print('fatal: Invalid gitfile format: .lgit')
        exit_program()
    for d in direcs:
        if os.path.isfile(d):
            print("%s: Not a directory" % (os.path.join(os.getcwd(), d)))
        else:
            os.makedirs(d)
    for f in files:
        if not os.path.isdir(f):
            open(f, 'w').close()
        else:
            print("error: unable to mmap '%s' Is a directory" %
                  (os.path.join(os.getcwd(), f)))
示例#5
0
def preprocesser(adapter, in_file1, in_file2, out_file):
    """preprocesses the fastq files with sicle and optionally cutadapt, writes logs of what was done, removes intermediary files
    keyword arguments:
        adapter: str, the adapter sequnce to be cut with cutadapt, make it an empty string ("") if running cutadapt is not required
        in_file1: str, the name of the (first) fastq file to be preprocessed
        in_file2: str, the name of the second fastq file if the sequence is paired ended, make it an empty string ("") if the sequence is single ended
        out_file: str, the desired name of the output fastq file
    WARNING: will remove all files in the working directory that start with "temp"
    """
    #start_time = time.time()
    #timelog(start_time,"process_start")

    if os.path.exists(in_file1):
        if adapter != "":
            if in_file2 == "":
                cmd = make_single_cutadapt_command(in_file1, "temp1.fq",
                                                   adapter)
                in_file1 = "temp1.fq"
            else:
                cmd = make_double_cutadapt_command(in_file1, in_file2,
                                                   "temp1.fq", "temp2.fq",
                                                   adapter)
                in_file1 = "temp1.fq"
                in_file2 = "temp2.fq"
            output = run_commandline(cmd)
            write_log("CUTADAPT", output)

            #timelog(start_time,"cutadapt")
        if in_file2 == "":
            cmd = make_single_sickle_command(in_file1, "preprocess.fastq")
        else:
            cmd = make_double_sickle_command(in_file1, in_file2,
                                             "preprocess1.fastq",
                                             "preprocess2.fastq")
        output = run_commandline(cmd)
        write_log("SICKLE", output)
        if adapter != "":
            cmd = "rm temp*.fq"
            run_commandline(cmd)
            #timelog(start_time,"sickle")
    else:
        stderr.write(arguments.input + "file not found\n")
        exit_program()
    return
示例#6
0
def menu():
    while True:
        print("""
        
-------------------------------------------------------------------------        
Metoda aproksymacji oparta o wielomiany Czebyszewa
Lukasz Janiszewski, Maciej Kubis""")
        print("""
Wybierz opcję:
1. Rozpocznij program
2. Zakończ program""")
        user_choice = int(input("""
Wybór: """))
        if user_choice == 1:
            data_load()
        elif user_choice == 2:
            exit_program()
        else:
            print("""Wybrano nieprawidlowa opcje!""")
示例#7
0
            print("Success")
            succeeded += 1
        else:
            print(
                f"Failed\nExpected: {test_info['expected']}\nGot: {output['roots']}"
            )
            failed += 1

        print(common, "\n")
    print(
        f'Succeeded={succeeded} -> {succeeded/len(tests)*100}%\nFailed={failed} -> {failed/len(tests)*100}%'
    )


while True:
    expression = input("Input: ")

    if expression:

        if expression == "exit":
            exit_program()

        elif expression == "run tests":
            run_test()

        elif expression == "more":
            more = not more
            print("Turned On") if more else print("Turned Off")
        else:
            print(solve(expression)['roots'])
示例#8
0
def _is_valid_stash(files):
    for f in files:
        if not os.access(f, os.R_OK):
            print_message.PERMISSION_DENIED_STASH(f)
            exit_program()
    return True
示例#9
0
while (not(is_valid_input)) : 

    print(menu_prompt)
    user_operation_choice = input("Enter option:").lower() 

    if (user_operation_choice in valid_choices):

        is_valid_input = True
    
    else:

        print("Invalid choice, please try again")

if (user_operation_choice == "a"): 

    message = input("Input your message:") 
    password = get_user_password()       
    result = encrypt(message, password)

elif (user_operation_choice == "b"):  

    ciphertext = input("Input the ciphertext in hexadecimal form (0x…) :")
    password = get_user_password()
    result = decrypt(ciphertext, password)

else:
    print("Exiting Program ....")
    exit_program(0)

print("Result: " + result)