示例#1
0
def get_passwords(args):
	"""
	Returns a dict of passwords for further use
	and creates passwords.txt in the bench user's home directory
	"""

	ignore_prompt = args.run_travis or args.without_bench_setup
	mysql_root_password, admin_password = '', ''
	passwords_file_path = os.path.join(os.path.expanduser('~' + args.user), 'passwords.txt')

	if not ignore_prompt:
		# set passwords from existing passwords.txt
		if os.path.isfile(passwords_file_path):
			with open(passwords_file_path, 'r') as f:
				passwords = json.load(f)
				mysql_root_password, admin_password = passwords['mysql_root_password'], passwords['admin_password']

		# set passwords from cli args
		if args.mysql_root_password:
			mysql_root_password = args.mysql_root_password
		if args.admin_password:
			admin_password = args.admin_password

		# prompt for passwords
		pass_set = True
		while pass_set:
			# mysql root password
			if not mysql_root_password:
				mysql_root_password = getpass.unix_getpass(prompt='Please enter mysql root password: '******'Re-enter mysql root password: '******'':
					mysql_root_password = ''
					continue

			# admin password
			if not admin_password:
				admin_password = getpass.unix_getpass(prompt='Please enter the default Administrator user password: '******'Re-enter Administrator password: '******'':
					admin_password = ''
					continue

			pass_set = False
	else:
		mysql_root_password = admin_password = '******'

	passwords = {
		'mysql_root_password': mysql_root_password,
		'admin_password': admin_password
	}

	if not ignore_prompt:
		with open(passwords_file_path, 'w') as f:
			json.dump(passwords, f, indent=1)

		print('Passwords saved at ~/passwords.txt')

	return passwords
示例#2
0
    def __init__(self, args, wrapper):
        self.wrapper = wrapper
        self.logger = self.wrapper.logger
        self.args = args
        if 'batch' in self.args:
            self.q = Queue(maxsize=self.args.batch)
        self.l_exec = LocalExec()
        self.output = dict()
        if getattr(self.args, 'user'):
            self.user = self.args.user
        else:
            self.user = self.l_exec.run_shell_cmd('whoami')['stdout']
        self.logger.info('Username for SSH connection: {0}'.format(self.user))
        # if self.user != 'root':
        self.logger.info('Going to prompt for password for SSH connection..')
        self.passwd = getpass.unix_getpass(
            'Please enter your password for SSH authentication: ')
        self.ldap_host = self.get_ldap_host()
        if self.ldap_host:
            print_func('Verifying credentials..', logger=self.logger)
            while not self.check_credentials():
                self.passwd = getpass.unix_getpass(
                    'ERROR: Incorrect password! Please try again: ')
            print_func('Credentials are valid!', logger=self.logger)
        else:
            print_func(
                'No LDAP host was found! The script will continue without validating credentials',
                logger=self.logger,
                level='warn')

        if 'batch' not in self.args:
            setattr(self.args, 'batch', 1)
示例#3
0
def get_passwords(args):
	"""
	Returns a dict of passwords for further use
	and creates passwords.txt in the bench user's home directory
	"""

	ignore_prompt = args.run_travis or args.without_bench_setup
	mysql_root_password, admin_password = '', ''
	passwords_file_path = os.path.join(os.path.expanduser('~' + args.user), 'passwords.txt')

	if not ignore_prompt:
		# set passwords from existing passwords.txt
		if os.path.isfile(passwords_file_path):
			with open(passwords_file_path, 'r') as f:
				passwords = json.load(f)
				mysql_root_password, admin_password = passwords['mysql_root_password'], passwords['admin_password']

		# set passwords from cli args
		if args.mysql_root_password:
			mysql_root_password = args.mysql_root_password
		if args.admin_password:
			admin_password = args.admin_password

		# prompt for passwords
		pass_set = True
		while pass_set:
			# mysql root password
			if not mysql_root_password:
				mysql_root_password = getpass.unix_getpass(prompt='Please enter mysql root password: '******'Re-enter mysql root password: '******''
					continue

			# admin password
			if not admin_password:
				admin_password = getpass.unix_getpass(prompt='Please enter the default Administrator user password: '******'Re-enter Administrator password: '******''
					continue

			pass_set = False
	else:
		mysql_root_password = admin_password = '******'

	passwords = {
		'mysql_root_password': mysql_root_password,
		'admin_password': admin_password
	}

	if not ignore_prompt:
		with open(passwords_file_path, 'w') as f:
			json.dump(passwords, f, indent=1)

		print('Passwords saved at ~/passwords.txt')

	return passwords
示例#4
0
文件: install.py 项目: dadasoz/bench
def get_passwords(ignore_prompt=False):
	if not ignore_prompt:
		mysql_root_password, admin_password = '', ''
		pass_set = True
		while pass_set:
			# mysql root password
			if not mysql_root_password:
				mysql_root_password = getpass.unix_getpass(prompt='Please enter mysql root password: '******'Re-enter mysql root password: '******''
					continue

			# admin password
			if not admin_password:
				admin_password = getpass.unix_getpass(prompt='Please enter Administrator password: '******'Re-enter Administrator password: '******''
					continue

			pass_set = False
	else:
		mysql_root_password = admin_password = '******'

	return {
		'mysql_root_password': mysql_root_password,
		'admin_password': admin_password
	}
示例#5
0
 def update_config(self):
     self.username = input("Mailer username: "******"Enter password: "******"linux" else getpass.win_getpass("Enter password: "******"Send to e-mail: ")
     self.noip_username = input("No-ip username: "******"Enter No-ip password: "******"linux" else getpass.win_getpass(
         "Enter No-ip password: "******"No-ip hostname: ")
     self.config["nodemailer"] = {
         "username": self.username,
         "password": self.password,
         "send_to": self.send_to
     }
     self.config["noip"] = {
         "username": self.noip_username,
         "password": self.noip_password,
         "hostname": self.noip_hostname
     }
     with open(self.config_path, "w") as configfile:
         self.config.write(configfile)
         configfile.close()
示例#6
0
 def test_flushes_stream_after_input(self):
     with mock.patch('os.open') as open, mock.patch(
             'io.FileIO'), mock.patch('io.TextIOWrapper'), mock.patch(
                 'termios.tcgetattr'), mock.patch('termios.tcsetattr'):
         open.return_value = 3
         mock_stream = mock.Mock(spec=StringIO)
         getpass.unix_getpass(stream=mock_stream)
         mock_stream.flush.assert_called_with()
def getpassword(prompt):
  if platform.system() == "Linux":
    return getpass.unix_getpass(prompt=prompt)
  elif platform.system() == "Windows" or platform.system() == "Microsoft":
    return getpass.win_getpass(prompt=prompt)
  elif platform.system() == "Macintosh":
    return getpass.unix_getpass(prompt=prompt)
  else:
    return getpass.getpass(prompt=prompt)
示例#8
0
 def test_uses_tty_directly(self):
     with mock.patch('os.open') as open, mock.patch(
             'io.FileIO') as fileio, mock.patch(
                 'io.TextIOWrapper') as textio:
         open.return_value = None
         getpass.unix_getpass()
         open.assert_called_once_with('/dev/tty', os.O_RDWR | os.O_NOCTTY)
         fileio.assert_called_once_with(open.return_value, 'w+')
         textio.assert_called_once_with(fileio.return_value)
示例#9
0
 def test_uses_tty_directly(self):
     with mock.patch('os.open') as open, \
             mock.patch('os.fdopen'):
         # By setting open's return value to None the implementation will
         # skip code we don't care about in this test.  We can mock this out
         # fully if an alternate implementation works differently.
         open.return_value = None
         getpass.unix_getpass()
         open.assert_called_once_with('/dev/tty',
                                      os.O_RDWR | os.O_NOCTTY)
示例#10
0
 def test_flushes_stream_after_input(self):
     # issue 7208
     with mock.patch('os.open') as open, \
             mock.patch('os.fdopen'), \
             mock.patch('termios.tcgetattr'), \
             mock.patch('termios.tcsetattr'):
         open.return_value = 3
         mock_stream = mock.Mock(spec=StringIO)
         getpass.unix_getpass(stream=mock_stream)
         mock_stream.flush.assert_called_with()
示例#11
0
 def test_resets_termios(self):
     with mock.patch('os.open') as open, mock.patch(
             'io.FileIO'), mock.patch('io.TextIOWrapper'), mock.patch(
                 'termios.tcgetattr') as tcgetattr, mock.patch(
                     'termios.tcsetattr') as tcsetattr:
         open.return_value = 3
         fake_attrs = [255, 255, 255, 255, 255]
         tcgetattr.return_value = list(fake_attrs)
         getpass.unix_getpass()
         tcsetattr.assert_called_with(3, mock.ANY, fake_attrs)
示例#12
0
 def test_resets_termios(self):
     with mock.patch('os.open') as open, \
             mock.patch('os.fdopen'), \
             mock.patch('termios.tcgetattr') as tcgetattr, \
             mock.patch('termios.tcsetattr') as tcsetattr:
         open.return_value = 3
         fake_attrs = [255, 255, 255, 255, 255]
         tcgetattr.return_value = list(fake_attrs)
         getpass.unix_getpass()
         tcsetattr.assert_called_with(3, mock.ANY, fake_attrs)
示例#13
0
 def test_falls_back_to_stdin(self):
     with mock.patch('os.open') as os_open, mock.patch(
             'sys.stdin', spec=StringIO) as stdin:
         os_open.side_effect = IOError
         stdin.fileno.side_effect = AttributeError
         with support.captured_stderr() as stderr:
             with self.assertWarns(getpass.GetPassWarning):
                 getpass.unix_getpass()
         stdin.readline.assert_called_once_with()
         self.assertIn('Warning', stderr.getvalue())
         self.assertIn('Password:', stderr.getvalue())
示例#14
0
 def test_falls_back_to_stdin(self):
     with mock.patch('os.open') as os_open, \
             mock.patch('sys.stdin', spec=StringIO) as stdin:
         os_open.side_effect = IOError
         stdin.fileno.side_effect = AttributeError
         with support.captured_stderr() as stderr:
             with self.assertWarns(getpass.GetPassWarning):
                 getpass.unix_getpass()
         stdin.readline.assert_called_once_with()
         self.assertIn('Warning', stderr.getvalue())
         self.assertIn('Password:', stderr.getvalue())
示例#15
0
 def test_falls_back_to_fallback_if_termios_raises(self):
     with mock.patch('os.open') as open, mock.patch(
             'io.FileIO') as fileio, mock.patch(
                 'io.TextIOWrapper') as textio, mock.patch(
                     'termios.tcgetattr'), mock.patch(
                         'termios.tcsetattr') as tcsetattr, mock.patch(
                             'getpass.fallback_getpass') as fallback:
         open.return_value = 3
         fileio.return_value = BytesIO()
         tcsetattr.side_effect = termios.error
         getpass.unix_getpass()
         fallback.assert_called_once_with('Password: ', textio.return_value)
示例#16
0
 def test_falls_back_to_fallback_if_termios_raises(self):
     with mock.patch('os.open') as open, \
             mock.patch('os.fdopen') as fdopen, \
             mock.patch('termios.tcgetattr'), \
             mock.patch('termios.tcsetattr') as tcsetattr, \
             mock.patch('getpass.fallback_getpass') as fallback:
         open.return_value = 3
         fdopen.return_value = StringIO()
         tcsetattr.side_effect = termios.error
         getpass.unix_getpass()
         fallback.assert_called_once_with('Password: ',
                                          fdopen.return_value)
示例#17
0
 def test_uses_tty_directly(self):
     with mock.patch('os.open') as open, \
             mock.patch('io.FileIO') as fileio, \
             mock.patch('io.TextIOWrapper') as textio:
         # By setting open's return value to None the implementation will
         # skip code we don't care about in this test.  We can mock this out
         # fully if an alternate implementation works differently.
         open.return_value = None
         getpass.unix_getpass()
         open.assert_called_once_with('/dev/tty', os.O_RDWR | os.O_NOCTTY)
         fileio.assert_called_once_with(open.return_value, 'w+')
         textio.assert_called_once_with(fileio.return_value)
示例#18
0
 def test_falls_back_to_fallback_if_termios_raises(self):
     with mock.patch('os.open') as open, \
             mock.patch('io.FileIO') as fileio, \
             mock.patch('io.TextIOWrapper') as textio, \
             mock.patch('termios.tcgetattr'), \
             mock.patch('termios.tcsetattr') as tcsetattr, \
             mock.patch('getpass.fallback_getpass') as fallback:
         open.return_value = 3
         fileio.return_value = BytesIO()
         tcsetattr.side_effect = termios.error
         getpass.unix_getpass()
         fallback.assert_called_once_with('Password: ',
                                          textio.return_value)
示例#19
0
def get_secret_literals():
    # Get the amount of literal secret key value pairs from the user
    local_dictionary = {}
    while True:
        local_threshold = input("How many secrets do you want to create? ")
        if not local_threshold.isdigit():
            print("Invalid input, enter positive integers only.")
            continue
        if int(local_threshold) < 1:
            print("Invalid input, enter positive integers only.")
            continue
        else:
            local_result = check_answer('Creating \'' + local_threshold +
                                        '\' secrets, is this correct? <y/n>: ')
            if local_result == 'y':
                break

    # Get the values of the literal secret key value pairs from the user and store them
    for i in range(int(local_threshold)):
        while True:
            local_current_key = input("Enter literal " + str(i + 1) +
                                      " secret key: ")
            local_current_key_repeat = input("Enter the secret key again: ")
            # TO DO - check for an underscore and fail if there, these aren't allowed in k8s object names.
            if local_current_key == local_current_key_repeat:
                print("Keys match, saving.")
                break
            else:
                print("Keys did not match, try again.")

        while True:
            # https://docs.python.org/3/library/getpass.html
            local_current_value = getpass.unix_getpass(
                prompt="Enter literal " + str(i + 1) + " secret value: ")
            local_current_value_repeat = getpass.unix_getpass(
                prompt="Enter the secret value again: ")
            if local_current_value == local_current_value_repeat:
                print("Values match, saving.")
                break
            else:
                print("Values did not match, try again.")

        local_dictionary[local_current_key] = local_current_value

    # Print literals when debugging
    for k, v in local_dictionary.items():
        logging.debug("dictionary - Key: '" + k + "' and Value: '" + v + "'")

    return local_dictionary
示例#20
0
文件: main.py 项目: urkh/Turpial
    def do_account(self, arg):
        if not self.__validate_arguments(ARGUMENTS['account'], arg):
            self.help_account(False)
            return False

        if arg == 'add':
            username = raw_input('Username: '******'Password: '******'Remember password')
            protocol = self.__build_protocols_menu()
            acc_id = self.core.register_account(username, protocol, password,
                                                remember)
            print 'Account added'
            if len(self.core.list_accounts()) == 1:
                self.__add_first_account_as_default()
        elif arg == 'edit':
            if not self.__validate_default_account():
                return False
            password = getpass.unix_getpass('New Password: '******'-')[0]
            protocol = self.account.split('-')[1]
            remember = self.__build_confirm_menu('Remember password')
            self.core.register_account(username, protocol, password, remember)
            print 'Account edited'
        elif arg == 'delete':
            if not self.__validate_accounts():
                return False
            account = self.__build_accounts_menu()
            conf = self.__build_confirm_menu(
                'Do you want to delete account %s?' % account)
            if not conf:
                print 'Command cancelled'
                return False
            del_all = self.__build_confirm_menu(
                'Do you want to delete all data?')
            self.core.unregister_account(account, del_all)
            if self.account == account:
                self.account = None
            print 'Account deleted'
        elif arg == 'change':
            if not self.__validate_accounts():
                return False
            self.__build_change_account_menu()
        elif arg == 'list':
            self.__show_accounts()
        elif arg == 'default':
            print "Your default account is %s in %s" % (
                self.account.split('-')[0], self.account.split('-')[1])
示例#21
0
def linuxonetime():
    URL = 'http://anqa01-liebweb1.vcloudqa-int.net/ERPMWebService/AuthService.svc/REST/'
    LxPwd1 = URL + 'StoredCredential'
    mgmt = input("Enter the Mgmt: \n")
    TgtAct = input("Enter the Target Account: \n")
    currentpwd = getpass.unix_getpass()
    #loginpwd = getpass.unix_getpass()
    server = input("Enter the server name: \n")
    DataA1 = {
        "AuthenticationToken": token,
        "AccountName": TgtAct,
        "AssetTag": "",
        "AssociatedGroup": mgmt,
        "Comment": "",
        "Namespace": server,
        "OverwriteSettings": 0,
        "Password": currentpwd,
        "SystemName": server
    }
    m = requests.post(LxPwd1,
                      data=json.dumps(DataA1),
                      headers=headers,
                      verify=False)
    print(m.content)
    print("JOB Status Code", m.status_code)
示例#22
0
def getpassword(prompt):
    if platform.system() == "Linux":
        return getpass.unix_getpass(prompt=prompt)
    elif platform.system() == "Windows" or platform.system() == "Microsoft":
        return getpass.win_getpass(prompt=prompt)
    else:
        return getpass.getpass(prompt=prompt)
示例#23
0
def main():
    aaretsFilNavn = input("Årets txt-fil med gjester: ")
    historikkFilNavn = input('Historikkfil: ')
    aar = datetime.now().year

    sint = Sinterklaas(aar, aaretsFilNavn, historikkFilNavn)
    sint.skrivUtOversikt()

    # Bruker kan godkjenne oversikten før den lagres til historikk!
    godkjent = input("Ser dette greit ut? [y/n]): ")
    print()

    if (godkjent.lower() == "y"):
        sint.oppdaterHistorikk()
        sint.skrivHistorikkTilFil("historikk" + str(aar) + ".txt")
    else:
        print("Kjør programmet på nytt for å prøve igjen.")
        return

    # Info til epost
    login = input('Oppgi brukernavn (gmail): ')
    passord = unix_getpass(prompt='Oppgi passord (gmail): ')
    gavebelop = input('Oppgi gavebeløp: ')
    dato = input('Oppgi dato (eks. December 3rd): ')
    kontakt = input('Oppgi kontaktperson: ')

    sint.sendemail(login + '@gmail.com', login, passord, gavebelop, dato,
                   kontakt)
示例#24
0
def plainText():
    for i in range(1):
        print("请输入你学校账户的SMTP服务器(一般情况下直接为你们的网址,比如mail.bjtu.edu.cn)")
        smtpAdd=input()
        server = smtplib.SMTP(smtpAdd,25)
        server.starttls()#加密传输
        server.ehlo()
        account=input("请输入账户:  ")
        password=getpass.unix_getpass("请输入密码:  ")
        server.login(account,password)
        msg = MIMEMultipart()
        # msg['From']="nidayede"
        # msg['To']="Dog"
        sub=input("请输入主题")
        msg['Subject']=sub
        message=input("请输入要发送的文本信息:   ")
        msg.attach(MIMEText(message))
        To=input("请输入收件人地址")
        a=input("是否要发送附件,是输入1,否则输入0:   ")
        if a=="0":
            text=msg.as_string()
            server.sendmail(account,To,text)
            print("发送成功")
        else:
            filename=input("输入文件路径:   ")
            attachment=open(filename,'rb')
            p=MIMEBase("1","2")
            p.set_payload(attachment.read())
            encoders.encode_base64(p)
            p.add_header('Content-Disposition', 'attachment', filename=filename)
            msg.attach(p) 
            text=msg.as_string()
            server.sendmail(account,To,text)
            print("发送成功")
def send_mail(recipent_email, city):
    get_page_source(city)
    user_email = '*****@*****.**'
    password = getpass.unix_getpass()
    msg = MIMEMultipart()
    msg['Subject'] = 'Wiki Image-' + city
    msg['From'] = user_email
    msg['To'] = recipent_email
    body = "Here i enclosed the wiki image"
    msg.attach(MIMEText(body, 'plain'))
    filename = city + ".jpeg"
    attachment = open("/home/joelrj/Documents/wiki images/" + city, "rb")
    part = MIMEBase('application', 'octet-stream')
    part.set_payload((attachment).read())
    encoders.encode_base64(part)
    part.add_header('Content-Disposition',
                    "attachment; filename= %s" % filename)
    msg.attach(part)
    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.starttls()
    server.login(user_email, password)
    text = msg.as_string()
    server.sendmail(user_email, recipent_email, text)
    server.quit()
    return 'mailsent'
示例#26
0
def run(db_name, drop=False):
    db = web.database(dbn='mysql', 
        db=db_name, 
        user=raw_input('User: '******'Password: ')
    )
    sql_cache.Cache.make_sql_table(db, drop)
def do_manual_login(nodename, verbose=True):
    '''
    Some transfer nodes aren't automated yet (we need some keys and
    stuff setup). For now just do some parts manually.

    '''

    from getpass import unix_getpass

    id_number = ENDPOINT_INFO[nodename]['endpoint_id']

    # Check if logged in.
    act_cmd = ['globus', 'endpoint', 'is-activated', id_number]
    out = subprocess.run(act_cmd, capture_output=True)

    # If logged in, don't bother with another login.
    if 'is activated' in out.stdout.decode('utf-8'):
        return True

    log.info(f"Require manual login to {nodename}")

    username = input("Username:")
    password = unix_getpass()

    cmd = [
        'globus', 'endpoint', 'activate', '--myproxy', id_number,
        '--myproxy-username', username, '--myproxy-password', password
    ]

    out = subprocess.run(cmd, capture_output=True)

    return True
示例#28
0
def get_password():
    if platform.system() == "Linux":
        return getpass.unix_getpass()
    elif platform.system() == "Windows" or platform.system() == "Microsoft":
        return getpass.win_getpass()
    else:
        return getpass.getpass()
示例#29
0
def main():
    global PASSWORD

    set_debug_file()
    logging.debug(
        str(datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')) +
        ' setting up log successful ')
    get_commands()
    logging.debug(
        str(datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')) +
        ' asking the user for there password ')
    PASSWORD = getpass.unix_getpass("Please enter your password: "******"redhat":
        logging.debug(
            str(datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')) +
            ' MODE was set to readhat ')
        temp = read_file()
        logging.debug(
            str(datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')) +
            ' reding from text file was successful ')
        red_hat_install(temp)

    elif MODE == "debian":
        logging.debug(
            str(datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')) +
            ' MODE was set to debian ')
        temp = read_file()
        logging.debug(
            str(datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')) +
            ' reading from text file was successful ')
        debian_install(temp)
示例#30
0
def create_session():
    print("Frappe Cloud credentials @ {}".format(remote_site))

    # take user input from STDIN
    username = click.prompt("Username").strip()
    password = getpass.unix_getpass()

    auth_credentials = {"usr": username, "pwd": password}

    session = requests.Session()
    login_sc = session.post(login_url, auth_credentials)

    if login_sc.ok:
        print("Authorization Successful! ✅")
        team = select_team(session)
        session.headers.update({
            "X-Press-Team": team,
            "Connection": "keep-alive"
        })
        return session
    else:
        handle_request_failure(
            message="Authorization Failed with Error Code {}".format(
                login_sc.status_code),
            traceback=False)
示例#31
0
    def fill_login_form(self, url, login):
        """Types 'login' and 'password' into a login form."""

        login_field, pwd_field = self.get_login_form()

        if not pwd_field:
            log.info('Searching a login form')
            login_field, pwd_field = self.search_login_form(url)

            if not pwd_field:
                log.critical('No login form found')
                return

        # Clear any text in the password field.
        pwd_field.clear()
        log.info('Filling login form')

        if not self.password:
            self.password = getpass.unix_getpass('Please enter your password: ')

        if login_field:
            pwd_field.send_keys(self.password)
        else:
            # Attempt to locate login field by hitting SHIFT + TAB
            pwd_field.send_keys(self.password, Keys.SHIFT, Keys.TAB)
            login_field = self.switch_to.active_element

        login_field.clear()
        login_field.send_keys(login, Keys.RETURN)

        # Wait for page to respond to the submit.
        sleep(TIME_TO_WAIT)
def get_passwords(ignore_prompt=False,
                  mysql_root_password='',
                  admin_password=''):
    if not ignore_prompt:
        pass_set = True
        while pass_set:
            # mysql root password
            if not mysql_root_password:
                mysql_root_password = getpass.unix_getpass(
                    prompt='Please enter mysql root password: '******'Re-enter mysql root password: '******''
                    continue

            # admin password
            if not admin_password:
                admin_password = getpass.unix_getpass(
                    prompt=
                    'Please enter the default Administrator user password: '******'Re-enter Administrator password: '******''
                    continue

            pass_set = False
    else:
        mysql_root_password = admin_password = '******'

    passwords = {
        'mysql_root_password': mysql_root_password,
        'admin_password': admin_password
    }

    if not ignore_prompt:
        passwords_file_path = os.path.join(os.path.expanduser('~'),
                                           'passwords.txt')
        with open(passwords_file_path, 'w') as f:
            json.dump(passwords, f, indent=1)

        print 'Passwords saved at ~/passwords.txt'

    return passwords
示例#33
0
 def __user_password(self, message):
     passwd = None
     while 1:
         passwd = getpass.unix_getpass(message)
         if passwd:
             return passwd
         else:
             print "Password can't be blank"
示例#34
0
文件: main.py 项目: Bouska/Turpial
 def do_account(self, arg):
     if not self.__validate_arguments(ARGUMENTS['account'], arg): 
         self.help_account(False)
         return False
     
     if arg == 'add':
         username = raw_input('Username: '******'Password: '******'Remember password')
         protocol = self.__build_protocols_menu()
         acc_id = self.core.register_account(username, protocol, password, remember)
         print 'Account added'
         if len(self.core.list_accounts()) == 1: 
             self.__add_first_account_as_default()
     elif arg == 'edit':
         if not self.__validate_default_account(): 
             return False
         password = getpass.unix_getpass('New Password: '******'-')[0]
         protocol = self.account.split('-')[1]
         remember = self.__build_confirm_menu('Remember password')
         self.core.register_account(username, protocol, password, remember)
         print 'Account edited'
     elif arg == 'delete':
         if not self.__validate_accounts(): 
             return False
         account = self.__build_accounts_menu()
         conf = self.__build_confirm_menu('Do you want to delete account %s?' %
             account)
         if not conf:
             print 'Command cancelled'
             return False
         del_all = self.__build_confirm_menu('Do you want to delete all data?')
         self.core.unregister_account(account, del_all)
         if self.account == account:
             self.account = None
         print 'Account deleted'
     elif arg == 'change':
         if not self.__validate_accounts():
             return False
         self.__build_change_account_menu()
     elif arg == 'list':
         self.__show_accounts()
     elif arg == 'default':
         print "Your default account is %s in %s" % (
             self.account.split('-')[0], self.account.split('-')[1])
示例#35
0
 def __user_password(self, message):
     passwd = None
     while 1:
         passwd = getpass.unix_getpass(message)
         if passwd:
             return passwd
         else:
             print "Password can't be blank"
示例#36
0
文件: main.py 项目: Bouska/Turpial
 def __build_password_menu(self, account):
     passwd = None
     while 1:
         passwd = getpass.unix_getpass("Password for '%s' in '%s': " % (
             account.split('-')[0], account.split('-')[1]))
         if passwd:
             return passwd
         else:
             print "Password can't be blank"
示例#37
0
 def login(self):
   """login to the forums"""
   #TODO: detect when login fails
   self.browser.open('http://forums.somethingawful.com/account.php?action=loginform')
   self.browser.select_form(predicate = lambda form: form.action == 'http://forums.somethingawful.com/account.php')
   self.browser['username'] = raw_input('username: '******'password'] = getpass.unix_getpass('password: '******'BAD PASSWORD') == -1
示例#38
0
 def request(self, method, path, json=None, params=None, iterator=0):
     if iterator >= 2:
         return
     try:
         self._request(method, path, json, params, self.credentials)
     except (AuthFailedException, NoCredentialsException):
         click.echo('Please provide correct password.')
         self.credentials.password = getpass.unix_getpass()
         self.request(method, path, json, params, iterator + 1)
示例#39
0
文件: cmd_ui.py 项目: encels/Turpial
 def show_login(self):
     try:
         usuario = raw_input('Username: '******'')
         exit(0)
     log.info('Autenticando')
     self.request_signin(usuario, password)
示例#40
0
 def show_login(self):
     try:
         usuario = raw_input('Username: '******'')
         exit(0)
     log.info('Autenticando')
     self.request_signin(usuario, password)
def test():
    from etl_test import etl_test
    import etl
    import getpass

    user = raw_input('Enter blogger username: ')
    password = getpass.unix_getpass("Enter your password:")
    gblog_conn = gblog_connector(user, password)
    gblog_service = gblog_conn.open()
    print gblog_service
def test():
    from etl_test import etl_test
    import etl
    import getpass

    user = raw_input('Enter blogger username: ')
    password = getpass.unix_getpass("Enter your password:")
    gblog_conn = gblog_connector(user, password)
    gblog_service = gblog_conn.open()
    print gblog_service
示例#43
0
文件: main.py 项目: urkh/Turpial
 def __build_password_menu(self, account):
     passwd = None
     while 1:
         passwd = getpass.unix_getpass(
             "Password for '%s' in '%s': " %
             (account.split('-')[0], account.split('-')[1]))
         if passwd:
             return passwd
         else:
             print "Password can't be blank"
示例#44
0
def test():
    from etl_test import etl_test
    import etl
    import getpass
    user = raw_input('Enter gmail username: '******'@gmail.com'
    password = getpass.unix_getpass("Enter your password:")
    test = etl_test.etl_component_test(gmail_in(user, password))
    test.check_output([{'phone_numbers': [''], 'postal_addresses': [''], 'emails': [''], 'title': ''}], 'main')
    # here add the details of the contact in your gmail in the above mentioned format
    res = test.output()
示例#45
0
def get_passwords(ignore_prompt=False):
	if not ignore_prompt:
		mysql_root_password, admin_password = '', ''
		pass_set = True
		while pass_set:
			# mysql root password
			if not mysql_root_password:
				mysql_root_password = getpass.unix_getpass(prompt='Please enter mysql root password: '******'Re-enter mysql root password: '******''
					continue

			# admin password
			if not admin_password:
				admin_password = getpass.unix_getpass(prompt='Please enter the default Administrator user password: '******'Re-enter Administrator password: '******''
					continue

			pass_set = False
	else:
		mysql_root_password = admin_password = '******'

	passwords = {
		'mysql_root_password': mysql_root_password,
		'admin_password': admin_password
	}

	if not ignore_prompt:
		passwords_file_path = os.path.join(os.path.expanduser('~'), 'passwords.txt')
		with open(passwords_file_path, 'w') as f:
			json.dump(passwords, f, indent=1)

		print 'Passwords saved at ~/passwords.txt'

	return passwords
示例#46
0
def test():
    from etl_test import etl_test
    import etl
    import getpass
    user = raw_input('Enter gmail username: '******'/home/tiny/Desktop/')
    test = etl_test.etl_component_test(in_doc)
#    test.check_output([{'phone_numbers': [''], 'postal_addresses': [''], 'emails': [''], 'title': ''}], 'main')
    # here add the details of the contact in your gmail in the above mentioned format
    res = test.output()
    print res
示例#47
0
def test():
    from etl_test import etl_test
    import etl
    import getpass
    user = raw_input('Enter gmail username: '******'/home/tiny/Desktop/')
    test = etl_test.etl_component_test(in_doc)
    #    test.check_output([{'phone_numbers': [''], 'postal_addresses': [''], 'emails': [''], 'title': ''}], 'main')
    # here add the details of the contact in your gmail in the above mentioned format
    res = test.output()
    print res
示例#48
0
def test():
    from etl_test import etl_test
    import etl
    import getpass
    user = raw_input('Enter gmail username: '******'', '/home/tiny/Desktop/1st Review.ppt','PPT')
#    out_doc = gdoc_out(doc_conn, '', '/home/tiny/Desktop/changes.doc','DOC')
    out_doc = gdoc_out(doc_conn, '', '/home/tiny/Desktop/NAME_IN_FULL.doc','DOC')
    test = etl_test.etl_component_test(out_doc)
#    test.check_output([{'phone_numbers': [''], 'postal_addresses': [''], 'emails': [''], 'title': ''}], 'main')
    res = test.output()
    print res
def encriptar():
    fragments = input(
        "Nombre de archivo donde se guardarán las evaluaciones (sin extensión): "
    )
    try:
        n = int(input("Número de evaluaciones: "))
        t = int(input("Número de evaluaciones minimas: "))
    except ValueError:
        sys.exit("Asegúrate de ingresar un valor númerico.")
    clear = input("Nombre de archivo a encriptar: ")
    password = getpass.unix_getpass("Contraseña: ")
    secret = Secret.Secret(password)
    secret.encrypt(clear)
    secret.fragments(t, n, fragments)
示例#50
0
def test():
    from etl_test import etl_test
    import etl
    import getpass
    user = raw_input('Enter gmail username: '******'', '/home/tiny/Desktop/1st Review.ppt','PPT')
    #    out_doc = gdoc_out(doc_conn, '', '/home/tiny/Desktop/changes.doc','DOC')
    out_doc = gdoc_out(doc_conn, '', '/home/tiny/Desktop/NAME_IN_FULL.doc',
                       'DOC')
    test = etl_test.etl_component_test(out_doc)
    #    test.check_output([{'phone_numbers': [''], 'postal_addresses': [''], 'emails': [''], 'title': ''}], 'main')
    res = test.output()
    print res
def test():
    """
    Test function.
    """
    from etl_test import etl_test
    import etl
    import getpass
    user = raw_input('Enter gmail username: ')
    password = getpass.unix_getpass("Enter your password:")
    gdoc_conn = gdoc_connector(user, password)
    gdoc_service = gdoc_conn.open()
    documents_feed = gdoc_service.GetDocumentListFeed()
    for document_entry in documents_feed.entry:
        # Display the title of the document on the command line.
        print document_entry.title.text
    print gdoc_service
def test():
    """
    Test function.
    """
    from etl_test import etl_test
    import etl
    import getpass

    user = raw_input("Enter gmail username: "******"Enter your password:")
    gdoc_conn = gdoc_connector(user, password)
    gdoc_service = gdoc_conn.open()
    documents_feed = gdoc_service.GetDocumentListFeed()
    for document_entry in documents_feed.entry:
        # Display the title of the document on the command line.
        print document_entry.title.text
    print gdoc_service
def test():
    from etl_test import etl_test
    import etl
    import getpass
    user = raw_input('Enter gmail username: '******'@gmail.com'
    password = getpass.unix_getpass("Enter your password:")
    cal_conn=etl.connector.gcalendar_connector(user, password)

    out_calendar = gcalendar_out(cal_conn,'%Y-%m-%d %H:%M:%S')

    test = etl_test.etl_component_test(out_calendar)
    ooconnector=openobject_connector('http://localhost:8069', 'trunk_mra', 'admin', 'admin',con_type='xmlrpc')
    oo_in_event = etl_test.etl_component_test(etl.component.input.openobject_in(
                     ooconnector,'event.event',
                     fields=['name', 'date_begin', 'date_end'],
    ))
    res = test.output()
示例#54
0
def main():
    global PASSWORD

    set_debug_file()
    logging.debug(str(datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')) + ' setting up log successful ')
    get_commands()
    logging.debug(str(datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')) + ' asking the user for there password ')
    PASSWORD = getpass.unix_getpass("Please enter your password: "******"redhat":
        logging.debug(str(datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')) + ' MODE was set to readhat ')
        temp = read_file()
        logging.debug(str(datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')) + ' reding from text file was successful ')
        red_hat_install(temp)

    elif MODE == "debian":
        logging.debug(str(datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')) + ' MODE was set to debian ')
        temp = read_file()
        logging.debug(str(datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')) + ' reading from text file was successful ')
        debian_install(temp)
def test():
    from etl_test import etl_test
    import etl
    from etl import transformer
    import getpass
    user = raw_input('Enter gmail username: '******'@gmail.com'
    password = getpass.unix_getpass("Enter your password:")
    cal_conn=etl.connector.gcalendar_connector(user, password)
    in_calendar = gcalendar_in(cal_conn)

    test = etl_test.etl_component_test(in_calendar)

#    transformer_description= {'date_begin':transformer.DATETIME, 'date_end':transformer.DATETIME}
#    transformer=transformer(transformer_description)

#    test.check_output([{'date_end': '2009-05-23 15:00:00', 'date_begin': '2009-05-23 14:00:00', 'name': 'Outing'}, {'date_end': '2009-05-23 10:00:00', 'date_begin': '2009-05-23 09:00:00', 'name': 'Reporting'}, {'date_end': '2009-06-07 00:00:00', 'date_begin': '2009-06-06 00:00:00', 'name': 'Submission'}], 'main')
    # here add the details of the contact in your gmail in the above mentioned format
#    test1 = gcalender_in_component=etl_test.etl_component_test(etl.component.input.gcalendar_in(cal_conn,transformer=transformer))
    res = test.output()
示例#56
0
def test():
    from etl_test import etl_test
    import etl
    import getpass
    user = raw_input('Enter gmail username: '******'@gmail.com'
    password = getpass.unix_getpass("Enter your password:")

    ooconnector=openobject_connector('http://localhost:8069', 'quality', 'admin', 'admin',con_type='xmlrpc')
    oo_in_event = etl_test.etl_component_test(etl.component.input.openobject_in(
                     ooconnector,'res.partner.address',
                     fields=['name', 'email', 'phone'],
    ))
    res = oo_in_event.output()

    test = etl_test.etl_component_test(gmail_out(user, password,res))

#    test.check_output([{'phone_numbers': [''], 'postal_addresses': [''], 'emails': [''], 'title': ''}], 'main')
    # here add the details of the contact in your gmail in the above mentioned format
    res = test.output()
示例#57
0
import couchdb
import getpass

admin = raw_input("Enter admin name: \n> ")
passwd = getpass.unix_getpass("Enter admin password: \n> ")

serveraddress = raw_input("Enter server address: "+'\n> ')
if not serveraddress:
	serveraddress = 'http://localhost:5984'

deviceID = raw_input("Enter deviceID: "+'\n> ')
devicePWD = raw_input("Chose a device password: "******"user already exists"
except couchdb.ResourceNotFound:
	userdoc = {"_id" : "org.couchdb.user:"******"name" : deviceID, "password" : devicePWD, "type" : "user", "roles" : []}
	userdb.save(userdoc)
	print('new user created: '+deviceID)

# create database

try:
	db = Server[deviceID]
示例#58
0
文件: utils.py 项目: freephys/mylab
def input_pass(user):
    import getpass
    return getpass.unix_getpass("password of %s:" %user)
示例#59
0
    ap.add_argument('-v','--version',action='version',version="Wraith-rt %s" % wraith.__version__)
    args = ap.parse_args()
    sopts = args.start
    stop = args.stop
    exclude = args.exclude

    # default is start nogui (make sure both start and stop are not specified)
    # if password is entered verified correctness
    if sopts is None and stop == False: sopts = 'gui'
    if sopts is not None and stop == True: ap.error("Cannot start and stop")

    # stop services - assumes no gui
    if stop:
        # verify pwd has been set
        i = 2
        pwd = getpass.unix_getpass(prompt="Password [for %s]:" % getpass.getuser())
        while not cmdline.testsudopwd(pwd) and i > 0:
            pwd = getpass.unix_getpass(prompt="Incorrect password, try again:")
            i -= 1
        if not pwd: ap.error("Three incorrect password attempts")

        # stop DySKT, then Nidus, then PostgreSQL
        sd = sn = sp = True
        if cmdline.dysktrunning(wraith.DYSKTPID):
            ret = 'ok' if stopdyskt(pwd) else 'fail'
            print "Stopping DySKT\t\t\t\t[%s]" % ret
        else: print "DySKT not running"
        if cmdline.nidusrunning(wraith.NIDUSPID):
            ret = 'ok' if stopnidus(pwd) else 'fail'
            print "Stopping Nidus\t\t\t\t[%s]" % ret
        else: print "Nidus not running"