Пример #1
0
def get_tests_to_upload(test_prefix='test_'):
    """Get information from the user regarding the files they are uploading via the API.

    Uses the inquirer command line user interface to query the user. The inquirer cli will validate
    all data submitted. A user may choose to upload a single file or upload an entire folder.
    Note - that when uploading a folder, all of the root folders' subdirectories will be searched
    for test files to upload. The default prefix for a test files is "test_".

        Args:
            test_prefix (str): The naming convention used for files containing test cases
            that should be uploaded to TestLink.

        Returns:
            A dict containing the data that will be uploaded. Either the the test_file key or
            test_folder will be returned depending on what type of upload the user has selected.
            Example:
                {'libs_dir': '/home/johndoe/test_project',
                 'test_file': 'home/johndoe/test_project/test_item.py'}

    """
    if inquirer.list_input('How many test files do you need to upload?',
                           choices=['Single', 'Multiple']) == 'Single':
        questions = [
            inquirer.Path('test_file',
                          message="Which test file are you uploading?",
                          path_type=inquirer.Path.FILE),
            inquirer.Path(
                'libs_dir',
                message="Whats the path to your projects library files?",
                path_type=inquirer.Path.DIRECTORY)
        ]
    else:
        questions = [
            inquirer.Path('test_folder',
                          message="Which test folder are you uploading?",
                          path_type=inquirer.Path.DIRECTORY),
            inquirer.Path(
                'libs_dir',
                message="Whats the path to your projects library files?",
                path_type=inquirer.Path.DIRECTORY)
        ]
    answers = inquirer.prompt(questions)
    files_to_upload = []

    if 'test_folder' in answers:
        for root, dirs, files in os.walk(answers['test_folder']):
            for file in files:
                if re.search(test_prefix + '.*.py$', file) is not None:
                    files_to_upload.append(root + '/' + file)
    else:
        files_to_upload.append(answers['test_file'])

    upload_data = {'tests': files_to_upload, 'libs_dir': answers['libs_dir']}
    upload_data['confirmed'] = confirm_upload(upload_data['tests'])
    return upload_data
Пример #2
0
def ciphertext_read_prompt() -> str:
    # Ask for ciphertext source
    ciphertext_source = inquirer.list_input("Choose ciphertext source",
                                            choices=["Manual Input", "File"])

    if ciphertext_source == "Manual Input":
        ciphertext_string = inquirer.text(message="ciphertext")

        return ciphertext_string

    elif ciphertext_source == "File":
        question = [
            inquirer.Path(
                "file_path",
                message="path to ciphertext file",
                path_type=inquirer.Path.FILE,
            ),
        ]

        ciphertext_file_path = inquirer.prompt(question)

        return hf.read_file_as_string_single_stripped(
            ciphertext_file_path['file_path'])

    else:
        raise NotImplementedError
Пример #3
0
def extended_vignere_cipher_get_key() -> bytearray:
    # Set up cipher key
    key_source = inquirer.list_input("Choose key source",
                                     choices=["Manual Input", "File"])

    if key_source == "Manual Input":
        key_string = inquirer.text(message="key")

        return key_string.encode('UTF-8')

    elif key_source == "File":
        question = [
            inquirer.Path(
                "file_path",
                message="path to key file",
                path_type=inquirer.Path.FILE,
            ),
        ]

        key_file_path = inquirer.prompt(question)

        return hf.read_file_as_bytearray(key_file_path['file_path'])

    else:
        raise NotImplementedError
Пример #4
0
def simple_key_read_prompt() -> str:
    # Set up cipher key
    key_source = inquirer.list_input("Choose key source",
                                     choices=["Manual Input", "File"])

    if key_source == "Manual Input":
        key_string = inquirer.text(message="key")

        return key_string

    elif key_source == "File":
        question = [
            inquirer.Path(
                "file_path",
                message="path to key file",
                path_type=inquirer.Path.FILE,
            ),
        ]

        key_file_path = inquirer.prompt(question)

        return hf.read_file_as_string_single_stripped(
            key_file_path['file_path'])

    else:
        raise NotImplementedError
Пример #5
0
    def create(self):
        config = ConfigParser()
        print("Looks like this is the first time you are running wrap.")

        _continue = inquirer.confirm(
            "Would you like to go through an interactive configuration wizard?", default=True)

        if not _continue:
            print("The configuration is incomplete. Manually fill in the ~/.wraprc with the required values")
            return

        print("Please provide the path to the script folder:")
        script_folder_prompt = \
            inquirer.Path('script_folder', normalize_to_absolute_path=True,
                          path_type=inquirer.Path.DIRECTORY, exists=True)

        prompt = inquirer.prompt([script_folder_prompt])

        config["Main"] = {
            "ScriptFolder": prompt.get("script_folder")
        }
        with open(self._path, "w") as fp:
            config.write(fp)

        print("Configuration has been successfully created.")
Пример #6
0
def hillCipher_cipher_get_key() -> str:
    # Set up cipher key
    key_source = inquirer.list_input("Choose key source",
                                     choices=["Manual Input", "File"])

    if key_source == "Manual Input":
        key_size = int(inquirer.text(message="key size (N x N)"))

        key_string = inquirer.text(message="key")

        key_list = [int(x) for x in key_string.split()]

        if len(key_list) != key_size**2:
            raise Exception("key length not valid")

        key = []

        for i in range(0, key_size):
            key_row = []
            for j in range(0, key_size):
                key_row.append(key_list[key_size * i + j])
            key.append(key_row)

        return key

    elif key_source == "File":
        question = [
            inquirer.Path(
                "file_path",
                message="path to key file",
                path_type=inquirer.Path.FILE,
            ),
        ]

        key_file_path = inquirer.prompt(question)

        key_string_list = hf.read_file_as_string_list_stripped(
            key_file_path['file_path'])

        key_size = int(key_string_list[0])

        key_list = [int(x) for x in key_string_list[1].split()]

        if len(key_list) != key_size**2:
            raise Exception("key length not valid")

        key = []

        for i in range(0, key_size):
            key_row = []
            for j in range(0, key_size):
                key_row.append(key_list[key_size * i + j])
            key.append(key_row)

        return key

    else:
        raise NotImplementedError
Пример #7
0
def ask_submodel_odb():
    """ Ask for the supplementary ODB file used by a restart """
    q = [
        inquirer.Path('filename',
                      message="Path to submodel ODB file (absolute)",
                      path_type=inquirer.Path.FILE,
                      default='submodel.odb',
                      exists=False),
    ]

    return inquirer.prompt(q)
Пример #8
0
def one_for_all(to_convert, to_save):
    questions = [
        inquirer.Path("palette",
                      path_type=inquirer.Path.FILE,
                      message="What file will be the palette?",
                      default="assets/cobblestone.png"),
        inquirer.Confirm("brightness", message="Map brightness?"),
        inquirer.Confirm("transparency", message="Map transparency?"),
        inquirer.Confirm("color", message="Map color?")
    ]
    answers = inquirer.prompt(questions)
    one.all_one(answers['palette'], to_convert, to_save, answers['brightness'],
                answers['transparency'], answers['color'])
Пример #9
0
def extended_vignere_cipher_encrypt(cipher: ExtendedVigenereCipher):
    # Ask for plain binary and where to store the result
    question = [
        inquirer.Path(
            "source",
            message="path to plain file",
            path_type=inquirer.Path.FILE,
        ),
        inquirer.Path(
            "destination",
            message="path for encrypted result",
            path_type=inquirer.Path.FILE,
        ),
    ]

    answer = inquirer.prompt(question)

    plain_data = hf.read_file_as_bytearray(answer['source'])

    encrypted_data = cipher.encrypt(plain_data)

    hf.write_file_from_bytearray(encrypted_data, answer['destination'])
Пример #10
0
def ask_submodel_odb():
    """ Ask for the supplementary ODB file used by a submodel """
    q = [
        inquirer.Path(
            "filename",
            message="Path to submodel ODB file (absolute)",
            path_type=inquirer.Path.FILE,
            default="submodel.odb",
            exists=False,
        )
    ]

    return inquirer.prompt(q)
Пример #11
0
def pixel_blocks(to_convert, to_save):
    questions = [
        inquirer.Path(
            "palette",
            path_type=inquirer.Path.DIRECTORY,
            message="What directory will contain the palette images?",
            default="assets/palette/"),
        inquirer.Text("palette_res",
                      message="What resolution are the palette images?",
                      default=16)
    ]
    answers = inquirer.prompt(questions)
    res = int(answers['palette_res'])
    bp.pixel_per_block((res, res), answers['palette'], to_save, to_convert)
Пример #12
0
def ask_scratch():
    """ scratch """

    questions = [
        inquirer.Path(
            "scratch",
            message="Path to shared scratch directory (absolute path)",
            path_type=inquirer.Path.DIRECTORY,
            default=config["slurm"]["shared_scratch"].get(),
            exists=False,
        )
    ]

    return inquirer.prompt(questions)
Пример #13
0
def main():
    """
    MAKE SURE YOU RUN THIS IN A TERMINAL.
    It will break (for example) using PyCharms' default running instance.
    (If using PyCharm) you can set 'Emulate Terminal' to true.
    """
    options = {
        'PNG Everything': png_all,
        'Grayscale': store_func(color.convert,
                                color.ColorPresets.grayscale.value),
        'Invert': store_func(color.convert, color.ColorPresets.invert.value),
        'Custom Color': custom,
        'One for All': one_for_all,
        'Pixel Blocks': pixel_blocks,
        'Copy .mcmeta': rp.copy_mcmeta,
        'Shuffle': store_func(color.convert, color.ColorPresets.shuffle.value)
    }

    questions = [
        inquirer.List("action",
                      message="What do you want to do?",
                      choices=options.keys()),
        inquirer.Path("to_convert",
                      path_type=inquirer.Path.DIRECTORY,
                      message="What folder do you want to convert?",
                      default="assets/convert/"),
        inquirer.Path("to_save",
                      path_type=inquirer.Path.DIRECTORY,
                      message="What folder do you want the results to be?",
                      default="assets/done/"),
    ]
    answers = inquirer.prompt(questions)
    rp.to_save = Path(answers['to_save'])
    rp.to_convert = Path(answers['to_convert'])

    func = answers['action']
    options[func](to_save=rp.to_save, to_convert=rp.to_convert)
Пример #14
0
def ask_scratch():
    """ scratch """

    print()

    questions = [
        inquirer.Path(
            'scratch',
            message="Path to shared scratch directory (absolute path)",
            path_type=inquirer.Path.DIRECTORY,
            default=config['slurm']['shared_scratch'].get(),
            exists=False,
        ),
    ]

    return inquirer.prompt(questions)
Пример #15
0
def firstTimeSetUp():
    """
    Generate a user config file for first-time setup
    """
    print("No user config found. Running first time setup")

    questions = [
        inquirer.Path(
            name="rootLocation",
            message=
            "Where would you like canvas sync's root store location to be? (Absolute Paths Please)",
            normalize_to_absolute_path=True)
    ]

    answers = inquirer.prompt(questions, theme=GreenPassion())

    if not path.exists(filePath := answers["rootLocation"]):
Пример #16
0
def user_prompts():
    """
    Prompt user for type of input data, listing defined options.
    """
    questions = [
        inquirer.List(
            'data_type',
            message="What is the source of your input data?",
            choices=['Text', 'Images'],
        ),
        inquirer.Path('data_directory_path',
                      message="What is the full path to the data directory?",
                      path_type=inquirer.Path.DIRECTORY,
                      default='/Users/whetzel/git/what-is-it/data/'),
    ]
    answers = inquirer.prompt(questions)

    return answers
Пример #17
0
def main():
    try:
        questions = [
            inquirer.Text("target_url", message="Enter the target login URL", validate=lambda _, x: x != ''),
            inquirer.List("user_provided_wordlist", message="Select an option", choices=[("Use Brutus' wordlist", "no"), ("Use a path-specified wordlist", "yes")]),
            inquirer.Path("wordlist", message="Enter the absolute path to desired wordlist", ignore=ignore_wordlist, validate=lambda _, x: x != '', path_type=inquirer.Path.FILE, exists=True),
            inquirer.Text("interval", message="Enter request interval in seconds", default="1", validate=lambda _, x: x != '')
            ]
        answers = inquirer.prompt(questions, raise_keyboard_interrupt=True)
        wordlist = answers["wordlist"] if answers["wordlist"] else "/Users/narcissus/Applications/Brutus/config/subdomains.txt"
        print(f"[+] Building subdomain map for {answers['target_url']}.")
        Scanner(answers["target_url"], wordlist, answers["interval"])
    except TypeError:
        pass
    except KeyboardInterrupt:
        print("\n[x] Subdomain mapping process terminated by user.\n")
    except:
        raise errors.ValidationError('', reason=f"[-] An error has occurred; most likely malformed input.")
Пример #18
0
def ask_ffj():
    """ Returns a dict with the answers """

    l = _list_inputfiles()
    questions = None
    if not l:
        questions = [
            inquirer.Path('ffjfile',
                          message="FFJ input file (absolute path)",
                          path_type=inquirer.Path.FILE,
                          exists=True),
        ]
    else:
        questions = [
            inquirer.List('ffjfile',
                          message=".ffj file to use (absolute path)",
                          choices=_list_inputfiles()),
        ]
    return inquirer.prompt(questions)
Пример #19
0
def main():
    #continu question if start it's ok
    questions = [
        inquirer.Text('domain',
                    message="Nom de domaine ?") ,
        inquirer.Path('folderCertif',
                 message="Où dois-je placer le certificat ?",
                 path_type=inquirer.Path.DIRECTORY,
                )
    ]    
    answers = inquirer.prompt(questions)
    
    # catch variable
    domain = answers['domain']
    folder_certif = answers['folderCertif']
    # test string
    is_string(domain)
    is_string(folder_certif)
    
    return domain + folder_certif
Пример #20
0
def ask_inp():
    """ Returns a dict with the answers """

    input_files = _list_inputfiles()
    # questions = None
    if not input_files:
        questions = [
            inquirer.Path(
                "inpfile",
                message="Input file (absolute path)",
                path_type=inquirer.Path.FILE,
                exists=True,
            )
        ]
    else:
        questions = [
            inquirer.List("inpfile",
                          message="Select input deck, *.inp file",
                          choices=input_files)
        ]

    return inquirer.prompt(questions)
Пример #21
0
def plaintext_write_prompt(plaintext: str):
    # Ask for plaintext destination
    destination = inquirer.list_input("Choose result destination",
                                      choices=["Terminal Output", "File"])

    if destination == "Terminal Output":
        print(plaintext)

    elif destination == "File":
        question = [
            inquirer.Path(
                "file_path",
                message="path to plaintext file",
                path_type=inquirer.Path.FILE,
            ),
        ]

        plaintext_file_path = inquirer.prompt(question)

        hf.write_file_from_string(plaintext, plaintext_file_path['file_path'])

    else:
        raise NotImplementedError
Пример #22
0
def where_is_dataset(directory):
    """
    where_is_dataset asks the user where the dataset is located.
    """
    try:
        folders = []
        for root, dirs, files in os.walk(directory):
            for d in dirs:
                if d not in IGNORED_FOLDERS_AND_FILES:
                    folders.append(os.path.relpath(os.path.join(root, d), "."))
    except Exception as e:
        logger.error("Can not get a list of folders in current directory.")
        folders = []

    folders = [i for i in folders if not i.startswith(".")]

    if folders:
        questions = [
            inquirer.List(
                "dataset_folder",
                message="Which folder contains the data file?",
                choices=folders,
            )
        ]
    else:
        questions = [
            inquirer.Path(
                "dataset_folder",
                message="Which folder will you place the data files?",
                path_type=inquirer.Path.DIRECTORY,
            )
        ]

    answers = inquirer.prompt(questions)
    dataset_folder = answers.get("dataset_folder")

    return dataset_folder
Пример #23
0
def ciphertext_write_prompt(ciphertext: str):
    # Ask for ciphertext destination
    destination = inquirer.list_input("Choose result destination",
                                      choices=["Terminal Output", "File"])

    group_by_five = inquirer.confirm("Group result by 5 characters?",
                                     default=False)

    if group_by_five:
        temporary_ciphertext = ""

        for idx, elem in enumerate(ciphertext):
            temporary_ciphertext += elem
            if idx % 5 == 4:
                temporary_ciphertext += " "

        ciphertext = temporary_ciphertext

    if destination == "Terminal Output":
        print(ciphertext)

    elif destination == "File":
        question = [
            inquirer.Path(
                "file_path",
                message="path to ciphertext file",
                path_type=inquirer.Path.FILE,
            ),
        ]

        ciphertext_file_path = inquirer.prompt(question)

        hf.write_file_from_string(ciphertext,
                                  ciphertext_file_path['file_path'])

    else:
        raise NotImplementedError
Пример #24
0
def main():
    try:
        questions = [
            inquirer.Text("target_url", message="Enter the target login URL", validate=lambda _, x: x != ''),
            inquirer.Text("username", message="Enter the target username", validate=lambda _, x: x != ''),
            inquirer.Path("wordlist", message="Enter the absolute path to desired wordlist", validate=lambda _, x: x != '', path_type=inquirer.Path.FILE, exists=True)
            ]
        answers = inquirer.prompt(questions, raise_keyboard_interrupt=True)
        
       
        data_obj = {
            "username": answers["username"],
            "password": "", 
            "Login" : "submit"
            }

        print(f"[+] Beginning brute force attempt on {answers['username']}.")
        brute_credentials(data_obj, answers["wordlist"], answers["target_url"])
    except TypeError:
        pass
    except KeyboardInterrupt:
        print("\n[x] Brute force attempt terminated by user.\n")
    except:
        raise errors.ValidationError('', reason=f"[-] An error has occurred; most likely malformed input.")
Пример #25
0
def ask_python():
    """ Returns a dict with the answers """

    l = _list_pythonfiles()
    questions = None
    if not l:
        questions = [
            inquirer.Path(
                "pythonfile",
                message="python input file (absolute path)",
                path_type=inquirer.Path.FILE,
                exists=True,
            )
        ]
    else:
        questions = [
            inquirer.List(
                "pytonfile",
                message=".py file to use (absolute path)",
                choices=_list_pythonfiles(),
            )
        ]

    return inquirer.prompt(questions)
Пример #26
0
    def start(self):  # type: () -> dict
        """
        Entry point for the bootstrap process.
        The process will gather required information for configuration and then return those information in dict which
        follows the utils.config.Config attribute's naming.
        """
        if platform.system() == 'Windows':
            return self._bootstrap_windows()

        click.secho(""" _____                 _   _____  _     _____ 
|_   _|               | | /  __ \| |   |_   _|
  | | ___   __ _  __ _| | | /  \/| |     | |  
  | |/ _ \ / _` |/ _` | | | |    | |     | |  
  | | (_) | (_| | (_| | | | \__/\| |_____| |_ 
  \_/\___/ \__, |\__, |_|  \____/\_____/\___/ 
            __/ | __/ |                       
           |___/ |___/                        
""", fg="red")

        click.echo("Welcome to Toggl CLI!\n"
                   "We need to setup some configuration before you start using this awesome tool!\n")

        click.echo("{} Your credentials will be stored in plain-text inside of the configuration!\n".format(
            click.style("Warning!", fg="yellow", bold=True)
        ))

        api_token = self.get_api_token()

        if api_token is None:
            self._exit()

        questions = [
            inquirer.List('default workspace', message="Should TogglCli use different default workspace from Toggl's "
                                                       "setting?",
                          choices=lambda answers: self._get_workspaces(api_token)),

            inquirer.Text('timezone', 'Timezone to use (value \'{}\', will keep Toggl\'s setting)'.format(self.TOGGL_TIMEZONE),
                          default=self.SYSTEM_TIMEZONE,
                          validate=lambda answers, current: current in pendulum.timezones
                                                            or current == self.SYSTEM_TIMEZONE
                                                            or current == self.TOGGL_TIMEZONE),

            inquirer.Confirm('file_logging', message="Enable logging of togglCli actions into file?", default=False),
            inquirer.Path('file_logging_path', message="Path to the log file", ignore=lambda x: not x['file_logging'],
                          default='~/.toggl_log'),
        ]

        answers = inquirer.prompt(questions)

        if answers is None:
            self._exit()

        click.echo("""
        Configuration successfully finished!
        
        If you want to enable command completion run: toggl config completion install
        
        Now continuing with your command:
        
        """)

        return self._map_answers(api_token=api_token, **answers)
Пример #27
0
def parse_field(field, ignore=None):
    """Parses the question field and returns a list of inquirer questions.

    :param jobbergate.appform.QuestionBase field: The question to parse
    :param ignore: function to decide if the question should be ignored/hidden
    :returns: inquirer question
    :rtype: inquirer.Question
    """
    if isinstance(field, appform.Text):
        return inquirer.Text(
            field.variablename,
            message=field.message,
            default=field.default,
            ignore=ignore,
        )

    if isinstance(field, appform.Integer):
        return inquirer.Text(
            field.variablename,
            message=field.message,
            default=field.default,
            validate=field.validate,
            ignore=ignore,
        )

    if isinstance(field, appform.List):
        return inquirer.List(
            field.variablename,
            message=field.message,
            choices=field.choices,
            default=field.default,
            ignore=ignore,
        )

    if isinstance(field, appform.Directory):
        return inquirer.Path(
            field.variablename,
            message=field.message,
            path_type=inquirer.Path.DIRECTORY,
            default=field.default,
            exists=field.exists,
            ignore=ignore,
        )

    if isinstance(field, appform.File):
        return inquirer.Path(
            field.variablename,
            message=field.message,
            path_type=inquirer.Path.FILE,
            default=field.default,
            exists=field.exists,
            ignore=ignore,
        )

    if isinstance(field, appform.Checkbox):
        return inquirer.Checkbox(
            field.variablename,
            message=field.message,
            choices=field.choices,
            default=field.default,
            ignore=ignore,
        )

    if isinstance(field, appform.Confirm):
        return inquirer.Confirm(
            field.variablename,
            message=field.message,
            default=field.default,
            ignore=ignore,
        )

    if isinstance(field, appform.BooleanList):
        retval = [
            inquirer.Confirm(
                field.variablename,
                message=field.message,
                default=field.default,
                ignore=ignore,
            )
        ]

        if field.whenfalse:
            retval.extend([
                parse_field(wf, ignore=field.ignore) for wf in field.whenfalse
            ])
        if field.whentrue:
            retval.extend([
                parse_field(wt, ignore=field.noignore) for wt in field.whentrue
            ])

        return retval

    if isinstance(field, appform.Const):
        return inquirer.Text(
            field.variablename,
            message="",
            default=field.default,
            ignore=True,
        )
Пример #28
0
        message="What size do you need?",
        choices=['Jumbo', 'Large', 'Standard', 'Medium', 'Small', 'Micro'],
    ),
]
answers = inquirer.prompt(questions)
pprint.pprint(answers)

# checkbox
questions = [
    inquirer.Checkbox(
        'interests',
        message="What are you interested in?",
        choices=[
            'Computers', 'Books', 'Science', 'Nature', 'Fantasy', 'History'
        ],
    ),
]
answers = inquirer.prompt(questions)
pprint.pprint(answers)

# path
questions = [
    inquirer.Path(
        'log_file',
        message="Where logs should be located?",
        path_type=inquirer.Path.DIRECTORY,  # requires trailing slash for dirs
    ),
]
answers = inquirer.prompt(questions)
pprint.pprint(answers)
Пример #29
0
def initialize_config(conf):
    def gitlabTokenValidator(others, token):
        if token == '':
            return True

        repository_path = others['repositoryPath']

        info = get_remote_info(repository_path)
        hostname = info['hostname']
        result = requests.get(f'https://{hostname}/api/v4/version',
                              headers={"private-token": token})

        if result.status_code == 404:
            print('')
            logger.error(
                f'Repository {repository_path} with remote {hostname} is probably not a gitlab remote'
            )

        return result.status_code == 200

    def togglTokenValidator(_, token):
        result = requests.get('https://www.toggl.com/api/v8/me',
                              auth=(token, 'api_token'))

        return result.status_code == 200

    def gitRepoValidator(_, path):
        return is_git_repo(path)

    def serverUrlValidator(_, url):
        return validators.url(url)

    def transformServerUrl(url):
        if not url.endswith('/'):
            return url + '/'
        else:
            return url

    repoDefault = (getcwd() + '/') if is_git_repo(getcwd()) else None

    questions = [
        inquirer.Text('repositoryPath',
                      message="Enter your repository path",
                      default=repoDefault,
                      validate=gitRepoValidator),
        inquirer.Text('gitlabToken',
                      message="Enter your gitlab token",
                      default='',
                      validate=gitlabTokenValidator),
        inquirer.Text('togglToken',
                      message="Enter your toggl token",
                      validate=togglTokenValidator),
        inquirer.Text('serverUrl',
                      message="Enter the tracking server url",
                      validate=serverUrlValidator),
        inquirer.Path('logsFile',
                      message="Enter the logs file path",
                      path_type=inquirer.Path.FILE,
                      default="/tmp/asrtt.log")
    ]

    answers = inquirer.prompt(questions)

    answers['serverUrl'] = transformServerUrl(answers['serverUrl'])

    conf.all(answers)
Пример #30
0
import glob
from dotenv import load_dotenv

load_dotenv('../.env_db')
PGUSER = os.getenv('POSTGRES_USER')
PGPASS = os.getenv('POSTGRES_PASSWORD')
PGHOST = 'postgresql'
PGDB = os.getenv('POSTGRES_DB')

# Create connection
pg_engine = create_engine(f"postgresql://{PGUSER}:{PGPASS}@{PGHOST}/{PGDB}")

questions = [
    inquirer.Path('data_dir',
                  message="Enter directory where the clean CSVs located(don't forget the trailing '/')",
                  path_type=inquirer.Path.DIRECTORY,
                  default='csv/'
                  ),
    inquirer.Text('table_name',
                  message="Type the name of the table in which to insert the data",
                  default='line_list'
                  )
]
alter_table_questions = [
    inquirer.Confirm(
        'add_column',
        message="Do you want to add this column to the line_list table?",
        default=False,
    )
]