def attempt_key_import(keyid, key_fullpath): """Ask user to import key.""" global IMPORTED print(SEPT) ig = InputGetter('\nDo you want to attempt to import keyid {}: (y/N) '.format(keyid)) import_key_answer = ig.get_answer() if import_key_answer in [None, False]: return False with cli_gpg_ctx() as ctx: err, _ = ctx.import_key(keyid) if err is not None: util.print_error(err.strerror) return False err, key_content = ctx.export_key(keyid) if err is not None: util.print_error(err.strerror) return False util.write_out(key_fullpath, key_content) print('\n') util.print_success('Public key id: {} was imported'.format(keyid)) err, content = ctx.display_keyinfo(key_fullpath) if err is not None: util.print_error('Unable to parse {}, will be removed'.format(key_fullpath)) os.unlink(key_fullpath) return False print("\n", content) ig = InputGetter(message='\nDo you want to keep this key: (Y/n) ', default='y') if ig.get_answer() is True: IMPORTED = content return True else: os.unlink(key_fullpath) return False
def deploy_job(conn, git_info): """ Deploy the specified job via the Jenkins server. :param conn: An instance of jenkins.Jenkins, as initialized by init_jenkins_conn() :param git_info: A dictionary of the working directory repository's git parameters, as returned by load_git_info() """ env_var_defaults = { 'REPO_DIR': None, 'BRANCH': 'master', } parameters = { env_var: os.environ.get(env_var, default_val) for env_var, default_val in env_var_defaults.items() if os.environ.get(env_var) or default_val } conn.build_job( util.deploy_job_name(git_info['job_name']), parameters=parameters, ) util.print_success( 'Submitted deployment job for branch {deploy_branch} to directory {deploy_dir}.' .format( deploy_branch=parameters.get('BRANCH', 'default'), deploy_dir=parameters.get('REPO_DIR', 'default'), ))
def main(): try: run_cppcheck() except util.CommandError as e: util.print_fail() print(e) sys.exit(e.code) util.print_success()
def print_result(self, result, err_msg=''): """Display verification results.""" global EMAIL package_name = '' if self.url is not None: package_name = os.path.basename(self.url) if result: msg = "{} verification was successful ({})".format(package_name, EMAIL) util.print_success(msg) else: msg = "{} verification failed {}".format(package_name, err_msg) util.print_error(msg)
def build_job(conn, git_info): """ Submit a job to the Jenkins server. :param conn: An instance of jenkins.Jenkins, as initialized by init_jenkins_conn() :param git_info: A dictionary of the working directory repository's git parameters, as returned by load_git_info() """ conn.build_job( util.test_job_name(git_info['job_name']), parameters={ 'BRANCH': git_info['branch'], }, ) util.print_success('Submitted build job to the CI server.')
user_input = str(input(u.bgcolors.OKBLUE + message + u.bgcolors.ENDC)) counter = 1 if user_input.lower() in prop.truthy_values: # user wants to exit the program operacion_seleccionada = input(prop.ask_for_operation) while operacion_seleccionada not in API: u.print_error(prop.key_error_message) operacion_seleccionada = input(prop.ask_for_operation) else: operando1 = int(input("Digite numero 1: \n")) operando2 = int(input("Digite numero 2: \n")) try: result = API[operacion_seleccionada](operando1, operando2) # TODO: more elegant is to find if there is a substring of the typed operation in the operations list u.print_success(f"Seleccionó: {operacion_seleccionada}") print(f"El Resultado es {result} \n") except ZeroDivisionError: u.print_error(prop.zero_division_message) except KeyError: u.print_error(prop.key_error_message) else: # user wants to exit exit_signal = True u.print_error("Hasta luego, lo esperamos de vuelta!")