def wrapper(*args, **kwargs): app_path = click.get_app_dir(APP_NAME, force_posix=True) path_config = os.path.join(app_path, 'config.ini') try: config = ConfigParser.RawConfigParser() config.read(path_config) username = config.get('user', 'username') password = config.get('user', 'password') redmine = Redmine('https://factory.ailove.ru/', username=username, password=password) redmine.auth() except (AuthError, ConfigParser.NoSectionError, ConfigParser.NoOptionError, OSError): raise click.ClickException(click.style('Error: Login/Password incorrect\n' 'Please use command: ailove login', fg='red')) return f(*args, **kwargs)
def check_auth(username, password): """This function is called to check if a username / password combination is valid. """ global redmine global current_user try: redmine = Redmine(REDMINE_SERVER_URL, username=username, password=password) current_user = redmine.auth() except AuthError: logger.error('Exception with Redmine authentificate. Username or password invalid.') return False return True
def wrapper(*args, **kwargs): app_path = click.get_app_dir(APP_NAME, force_posix=True) path_config = os.path.join(app_path, 'config.ini') try: config = ConfigParser.RawConfigParser() config.read(path_config) username = config.get('user', 'username') password = config.get('user', 'password') redmine = Redmine('https://factory.ailove.ru/', username=username, password=password) redmine.auth() except (AuthError, ConfigParser.NoSectionError, ConfigParser.NoOptionError, OSError): raise click.ClickException( click.style( 'Error: Login/Password incorrect\n' 'Please use command: ailove login', fg='red')) return f(*args, **kwargs)
def login(username, password): err = False for cmd_name, required in REQUIRE_CMDS.items(): click.echo('Check command: {} ... '.format(cmd_name), nl=False) if not check_command_exists(cmd_name) and required: err = True click.secho('requires installation', fg='red') elif not check_command_exists(cmd_name) and not required: click.secho('desirable to install', fg='yellow') else: click.secho('OK', fg='green') if err: click.secho('Please install the required packages', fg='red') return try: redmine = Redmine(REDMINE_URL, username=username, password=password) redmine.auth() except AuthError: click.secho('Error: Login/Password incorrect', fg='red') return app_path = click.get_app_dir(APP_NAME, force_posix=True) if not os.path.exists(app_path): os.makedirs(app_path) config = ConfigParser.RawConfigParser() path_config = os.path.join(app_path, 'config.ini') config.add_section('user') config.set('user', 'username', username) config.set('user', 'password', password) with open(path_config, 'wb') as configfile: config.write(configfile)
Creates a new issue/ticket on redmine for the given information. """ redmine = Redmine(redmine_url,username=username,password=password) redmine.issue.create(project_id=project_id,subject=issue_subject,description=issue_subject,assigned_to_id=assign_to) if __name__ == "__main__": # Password and username input is for testing, I didn't want to leave my password up on github # Ideally when this is deployed, an external library will be imported with the settings. username = input("username:"******"password:"******"https://digitalscholarship.utsc.utoronto.ca/redmine" # Location of redmine redmine = Redmine(redmine_url,username=username,password=password) # connect to redmine redmine.auth() test_proj = redmine.project.get('test-project-kim3') # print(test_proj) create_redmine_issue(username,password,redmine_url,'test-project-kim2',"TEST SUBJECT", "TEST DESCRIPTION") projects = redmine.project.all() for proj in projects: print(proj.name) print(proj.identifier)
redmine = Redmine(redmine_url, username=username, password=password) redmine.issue.create(project_id=project_id, subject=issue_subject, description=issue_subject, assigned_to_id=assign_to) if __name__ == "__main__": # Password and username input is for testing, I didn't want to leave my password up on github # Ideally when this is deployed, an external library will be imported with the settings. username = input("username:"******"password:"******"https://digitalscholarship.utsc.utoronto.ca/redmine" # Location of redmine redmine = Redmine(redmine_url, username=username, password=password) # connect to redmine redmine.auth() test_proj = redmine.project.get('test-project-kim3') # print(test_proj) create_redmine_issue(username, password, redmine_url, 'test-project-kim2', "TEST SUBJECT", "TEST DESCRIPTION") projects = redmine.project.all() for proj in projects: print(proj.name) print(proj.identifier)