Esempio n. 1
0
def main():
    console.clear()
    if RESET_LOGIN:
        keychain.delete_password('iTunesConnect', 'Default')
    user, password, vendor_id = get_login()
    # Create the data folder:
    data_dir = 'ITCData'
    try:
        os.mkdir(data_dir)
    except OSError:
        pass
    # Load exchange rates (cached for 12 hours):
    rates = load_exchange_rates(os.path.join(data_dir, 'ExchangeRates.json'))
    # Load sales reports for the last 30 days:
    print 'Loading sales reports...\n'
    today = datetime.datetime.now()
    for i in xrange(30, 0, -1):
        d = today - datetime.timedelta(i)
        date_str = '%04i%02i%02i' % (d.year, d.month, d.day)
        display_date_str = '%04i-%02i-%02i' % (d.year, d.month, d.day)
        try:
            report = load_report(user, password, vendor_id, date_str, data_dir)
            print_report_summary(display_date_str, report, rates, CURRENCY)
        except ITCDownloadError, e:
            print 'Download failed for', display_date_str, '---', e
Esempio n. 2
0
def git_push(args):
    parser = argparse.ArgumentParser(prog='git push'
                                     , usage='git push [http(s)://<remote repo> or remote] [-u username[:password]]'
                                     , description="Push to a remote repository")
    parser.add_argument('url', type=str, nargs='?', help='URL to push to')
    parser.add_argument('-u', metavar='username[:password]', type=str, required=False, help='username[:password]')
    result = parser.parse_args(args)

    user, sep, pw = result.u.partition(':') if result.u else (None,None,None)

    repo = _get_repo()

    origin='origin'
    if not result.url:
        result.url = repo.remotes.get('origin','')
    if result.url in repo.remotes:
        origin=result.url
        result.url=repo.remotes.get(origin)

    branch_name = os.path.join('refs','heads', repo.active_branch)  #'refs/heads/%s' % repo.active_branch

    print "Attempting to push to: {0}, branch: {1}".format(result.url, branch_name)

    netloc = urlparse.urlparse(result.url).netloc

    keychainservice = 'stash.git.{0}'.format(netloc)

    if sep and not user:
        # -u : clears keychain for this server
        for service in keychain.get_services():
            if service[0]==keychainservice:
                keychain.delete_password(*service)

    #Attempt to retrieve user
    if not user and SAVE_PASSWORDS and result.url.startswith('http'):
        try:
            user = dict(keychain.get_services())[keychainservice]
        except KeyError:
            user = raw_input('Enter username: '******'Enter password: '******'Enter credentials for {0}'.format(netloc))

    if user:
        if not pw and SAVE_PASSWORDS:
            pw = keychain.get_password(keychainservice, user)

        #Check again, did we retrieve a password?
        if not pw:
            user, pw = console.login_alert('Enter credentials for {0}'.format(netloc), login=user)
            #pw = getpass.getpass('Enter password for {0}: '.format(user))
        host_with_auth='{}:{}@{}'.format(user,pw,netloc)
        url=urlparse.urlunparse(
            urlparse.urlparse(result.url)._replace(
                netloc=host_with_auth))
        porcelain.push(repo.repo.path, url, branch_name)
        keychain.set_password(keychainservice, user, pw)

    else:
        porcelain.push(repo.repo.path, result.url, branch_name)
    print 'success!'
Esempio n. 3
0
def delete_password(args):
  if keychain.get_password(KEYCHAIN_ID, args['user']) is None:
    LOG.error("No password was set for %s" % (args['user']))
    return False
  else:
    keychain.delete_password(KEYCHAIN_ID, args['user'])
    LOG.info("Deleted credentials for %s" % (args['user']))
    return True
Esempio n. 4
0
def test_against_pythonista_keychain():
    import keychain

    set_password('s', 'a', 'password')
    assert (keychain.get_password('s', 'a') == 'password')

    keychain.set_password('s', 'a', 'anotherone')
    assert (get_password('s', 'a') == 'anotherone')

    keychain.delete_password('s', 'a')
    assert (get_password('s', 'a') is None)
Esempio n. 5
0
 def interpret_error(self, error):
     if self.tool_sync_config.webdav.username and '401 Unauthorized' in error:
       self.short_error_text = "Authentication failed"
       logger.info("Authentication error: resetting password in keychain")
       keychain.delete_password(self.get_webdav_service_name(), self.tool_sync_config.webdav.username)
       
     elif 'Connection refused' in error:
       self.short_error_text = "Server unreachable/down"
       
     else:
       self.short_error_text = "Cause unknown"
Esempio n. 6
0
def reset_dropbox(username):
    """resets the dropbox configuration for the user username"""
    try:
        db = get_dropbox_client(username, setup=False)
    except:
        db = None
    if hasattr(db, "auth_token_revoke"):
        try:
            db.auth_token_revoke()
        except:
            pass
    keychain.delete_password(DB_SERVICE, username)
Esempio n. 7
0
    def git_push(args):
        parser = argparse.ArgumentParser(prog='git push'
                                         , usage='git push [http(s)://<remote repo>] [-u username[:password]]'
                                         , description="Push to a remote repository")
        parser.add_argument('url', type=str, nargs='?', help='URL to push to')
        parser.add_argument('-u', metavar='username[:password]', type=str, required=False, help='username[:password]')
        result = parser.parse_args(args)

        user, sep, pw = result.u.partition(':') if result.u else (None,None,None)

        repo = _get_repo()
        
        #Try to get the remote origin
        if not result.url:
            result.url = repo.remotes.get('origin','')

        branch_name = os.path.join('refs','heads', repo.active_branch)  #'refs/heads/%s' % repo.active_branch

        print "Attempting to push to: {0}, branch: {1}".format(result.url, branch_name)

        netloc = urlparse.urlparse(result.url).netloc

        keychainservice = 'shellista.git.{0}'.format(netloc)

        if sep and not user:
            # -u : clears keychain for this server
            for service in keychain.get_services():
                if service[0]==keychainservice:
                    keychain.delete_password(*service)

        #Attempt to retrieve user
        if not user and SAVE_PASSWORDS:
            try:
                user = dict(keychain.get_services())[keychainservice]
            except KeyError:
                user, pw = console.login_alert('Enter credentials for {0}'.format(netloc))

        if user:
            if not pw and SAVE_PASSWORDS:
                pw = keychain.get_password(keychainservice, user)

            #Check again, did we retrieve a password?
            if not pw:
                user, pw = console.login_alert('Enter credentials for {0}'.format(netloc), login=user)
                #pw = getpass.getpass('Enter password for {0}: '.format(user))

            opener = auth_urllib2_opener(None, result.url, user, pw)

            porcelain.push(repo.repo, result.url, branch_name, opener=opener)
            keychain.set_password(keychainservice, user, pw)

        else:
            porcelain.push(repo.repo, result.url, branch_name)
Esempio n. 8
0
def reset_dropbox(username):
	"""resets the dropbox configuration for the user username"""
	try:
		db = get_dropbox_client(username, setup=False)
	except:
		db = None
	if hasattr(db, "auth_token_revoke"):
		try:
			db.auth_token_revoke()
		except:
			pass
	keychain.delete_password(DB_SERVICE, username)
Esempio n. 9
0
def get_password_from_keychain(service, account, message=None):
  ''' Retrieve the working copy key or prompt for a new one. See https://github.com/ahenry91/wc_sync
  '''
  
  if not message:
    message = "Enter password for account '%s' of service '%s'" % (account, service)
  key = keychain.get_password(service, account)
  if not key:
    try:
      key = console.password_alert(message)
    except KeyboardInterrupt as k:
      key = None
    
    if key:
      keychain.set_password(service, account, key)
    else:
      keychain.delete_password(service, account)
  return key  
  
Esempio n. 10
0
    def resetPW(self, sender):
        repo = self._get_repo()

        remote = self.view['remote'].text
        if remote in self.remotes_iterator():
            remote = repo.remotes.get(remote, '')

        branch_name = os.path.join('refs', 'heads', repo.active_branch)  # 'refs/heads/%s' % repo.active_branch
        # tODO  use remote branch_name

        netloc = urlparse.urlparse(remote).netloc

        keychainservice = 'shellista.git.{0}'.format(netloc)
        try:
            user = dict(keychain.get_services())[keychainservice]
            keychain.delete_password(keychainservice, user)
            console.hud_alert('removed password for {}@{}'.format(user, netloc))
        except KeyError:
            console.hud_alert('no saved auth for {}'.format(netloc))
Esempio n. 11
0
    def resetPW(self,sender):
        repo = self._get_repo()
        
        remote=self.view['remote'].text
        if remote in self.remotes_iterator():
            remote = repo.remotes.get(remote,'')

        branch_name = os.path.join('refs','heads', repo.active_branch)  #'refs/heads/%s' % repo.active_branch
        # tODO  use remote branch_name 


        netloc = urlparse.urlparse(remote).netloc

        keychainservice = 'shellista.git.{0}'.format(netloc)
        try:
            user = dict(keychain.get_services())[keychainservice]
            keychain.delete_password(keychainservice,user)
            console.hud_alert('removed password for {}@{}'.format( user,netloc))
        except KeyError:
            console.hud_alert('no saved auth for {}'.format( netloc))
Esempio n. 12
0
 def btn_secret_push(self, sender):
     tmpsecret = self.secret
     if tmpsecret is None:
         tmpsecret = ''
     tmpsecret = dialogs.text_dialog(
         title='Set secret',
         text=tmpsecret,
         autocorrection=False,
         autocapitalization=ui.AUTOCAPITALIZE_NONE,
         spellchecking=False)
     if tmpsecret is None:
         return
     tmpsecret = tmpsecret.strip()
     if tmpsecret:
         keychain.set_password(appname, appname, tmpsecret)
         self.secret = tmpsecret
         self.activate_button()
     else:
         keychain.delete_password(appname, appname)
         self.secret = None
         self.deactivate_button()
Esempio n. 13
0
	def edit_config(self):
		config = dialogs.form_dialog(title='Movie Diary Configuration', sections=[('MovieDB', [{'type': 'text', 'key': 'moviedb_api', 'value': self.moviedb_api, 'title': 'MovieDB API Token'}]), ('Airtable', [{'type': 'text', 'key': 'airtable_api', 'value': self.airtable_api, 'title': 'Airtable API Key'}, {'type': 'text', 'key': 'airtable_db', 'value': self.airtable_db, 'title': 'Airtable database ID'}, {'type': 'text', 'key': 'airtable_table', 'value': self.airtable_table, 'title': 'Airtable table name'}]), ('Custom', [{'type': 'switch', 'key': 'set_date_manually', 'value': self.set_date_manually, 'title': 'Set date manually'}, {'type': 'switch', 'key': 'add_time_to_date', 'value': self.add_time_to_date, 'title': 'Add time to date'}]),('Extra Fields', [{'type': 'switch', 'key': 'directors_field', 'value': self.directors_field, 'title': 'Directors'}, {'type': 'switch', 'key': 'genres_field', 'value': self.genres_field, 'title': 'Genres'}, {'type': 'switch', 'key': 'runtime_field', 'value': self.runtime_field, 'title': 'Runtime'}, {'type': 'switch', 'key': 'cast_field', 'value': self.cast_field, 'title': 'Cast'}, {'type': 'switch', 'key': 'imdb_field', 'value': self.imdb_field, 'title': 'IMDB URL'}]),('Fields', [{'type':'text', 'key': 'title_field_name', 'value': self.title_field_name, 'title': 'Title'}, {'type':'text', 'key': 'overview_field_name', 'value': self.overview_field_name, 'title': 'Overview'}, {'type':'text', 'key': 'rating_field_name', 'value': self.rating_field_name, 'title': 'Rating'}, {'type':'text', 'key': 'date_field_name', 'value': self.date_field_name, 'title': 'Date'}, {'type':'text', 'key': 'directors_field_name', 'value': self.directors_field_name, 'title': 'Directors'}, {'type':'text', 'key': 'poster_field_name', 'value': self.poster_field_name, 'title': 'Poster'}, {'type':'text', 'key': 'year_field_name', 'value': self.year_field_name, 'title': 'Year'}, {'type':'text', 'key': 'genres_field_name', 'value': self.genres_field_name, 'title': 'Genres'}, {'type':'text', 'key': 'cast_field_name', 'value': self.cast_field_name, 'title': 'Cast'}, {'type':'text', 'key': 'runtime_field_name', 'value': self.runtime_field_name, 'title': 'Runtime'}, {'type':'text', 'key': 'imdb_field_name', 'value': self.imdb_field_name, 'title': 'IMDB URL'}]), ('Serious Stuff', [{'type': 'switch', 'key': 'reset_config', 'title': 'Reset Configuration', 'value': False}])])

		if config != None:
			
			if config['reset_config']:
				reset_confirm = console.alert('Reset Configuration?', 'Are you sure? This will only clean your credentials data and has no relation to your database.', 'Cancel', 'Reset', hide_cancel_button=True)
				
				if reset_confirm == 2:
					keychain.delete_password('Movie Diary', 'Config')
					keychain.delete_password('Airtable', 'API')
					keychain.delete_password('Airtable', 'Movie Diary')
					keychain.delete_password('Airtable', 'Movie Diary Table')
					return console.hud_alert('Movie Diary Configuration Successfully Reset')
				
			config['moviedb_api'] = self.validate_config(config['moviedb_api'], 'Insert your TMDB API key', 'You need a valid MovieDB API key', '84cef43ccf02b1ba6093c9694ed671c9')
			config['airtable_api'] = self.validate_config(config['airtable_api'], 'Insert your Airtable API key', 'You need a valid Airtable API key')
			config['airtable_db'] = self.validate_config(config['airtable_db'], 'Insert your Airtable database ID', 'You need the ID of your database')
			config['airtable_table'] = self.validate_config(config['airtable_table'], 'Insert the name of yout Airtable table', 'You must insert the name of the table in your database.', 'Table 1', True)

			keychain.set_password('Movie Diary', 'Config', cPickle.dumps(config))
			console.hud_alert('Movie Diary Configuration Successfully Edited')
		else:
			raise MissingConfigError('You must setup and confirm the Movie Diary configuration before continuing.')
Esempio n. 14
0
 def __delitem__(self, key):
     for service in keychain.get_services():
         if key in service:
             keychain.delete_password(self._dbname, key)
Esempio n. 15
0
File: git.py Progetto: zx110101/00
def git_push(args):
    parser = argparse.ArgumentParser(
        prog='git push',
        usage=
        'git push [http(s)://<remote repo> or remote] [-u username[:password]]',
        description="Push to a remote repository")
    parser.add_argument('url', type=str, nargs='?', help='URL to push to')
    parser.add_argument('-u',
                        metavar='username[:password]',
                        type=str,
                        required=False,
                        help='username[:password]')
    result = parser.parse_args(args)

    user, sep, pw = result.u.partition(':') if result.u else (None, None, None)

    repo = _get_repo()

    origin = 'origin'
    if not result.url:
        result.url = repo.remotes.get('origin', '')
    if result.url in repo.remotes:
        origin = result.url
        result.url = repo.remotes.get(origin)

    branch_name = os.path.join(
        'refs', 'heads',
        repo.active_branch)  #'refs/heads/%s' % repo.active_branch

    print("Attempting to push to: {0}, branch: {1}".format(
        result.url, branch_name))

    netloc = urlparse.urlparse(result.url).netloc

    keychainservice = 'stash.git.{0}'.format(netloc)

    if sep and not user:
        # -u : clears keychain for this server
        for service in keychain.get_services():
            if service[0] == keychainservice:
                keychain.delete_password(*service)

    #Attempt to retrieve user
    if not user and SAVE_PASSWORDS and result.url.startswith('http'):
        try:
            user = dict(keychain.get_services())[keychainservice]
        except KeyError:
            user = input('Enter username: '******'Enter password: '******'Enter credentials for {0}'.format(netloc))

    outstream = StringIO()
    if user:
        if not pw and SAVE_PASSWORDS:
            pw = keychain.get_password(keychainservice, user)

        #Check again, did we retrieve a password?
        if not pw:
            user, pw = console.login_alert(
                'Enter credentials for {0}'.format(netloc), login=user)
        host_with_auth = '{}:{}@{}'.format(user, pw, netloc)
        url = urlparse.urlunparse(
            urlparse.urlparse(result.url)._replace(netloc=host_with_auth))
        porcelain.push(repo.repo.path, url, branch_name, errstream=outstream)
        keychain.set_password(keychainservice, user, pw)

    else:
        porcelain.push(repo.repo.path,
                       result.url,
                       branch_name,
                       errstream=outstream)

    for line in outstream.getvalue().split('\n'):
        print((line.replace(pw, '*******') if pw else line))

    print('success!')
Esempio n. 16
0
def clearSecret():
    keychain.delete_password(keychain_service, keychain_account)
    print('Done.')
Esempio n. 17
0
 def __delitem__(self, key):
   for service in keychain.get_services():
     if key in service:
       keychain.delete_password(DB_NAME, key)
Esempio n. 18
0
				Passing "*" downloads the current dir.
			'MODE': How to handle the files. Possible values:
				"r" or "R": only download the files. Changes will be discarded.
				"w" or "W": download the files and upload the changes after
					the command has been executed.
			'COMMAND' and 'ARGS':
				passed to the shell-subcommand.
		INFO:
			Currently, file deletions are never transferred, regardless of mode.
			
			In "w"-mode, only previously downloaded files are uploaded.
			(You can simple use '*' as a path)
			
			At the moment, there is a bug when trying to run a script in
				a dir which is not the current dir (e.g. tests/test.py).
			However, you can simply cd into the target dir and run the
				script from there.
"""
		self.stdout.write(av+"\n")

if __name__ == "__main__":
	parser = argparse.ArgumentParser(description=__doc__)
	parser.add_argument(
		"--reset_dropbox", action="store_true",
		help="resets the dropbox configuration", dest="db_reset")
	ns = parser.parse_args()
	if ns.db_reset:
		keychain.delete_password("stash:mc", "dropbox")
		sys.stdout.write(Text("Dropbox configuration deleted.\n", "red"))
	McCmd().cmdloop()
Esempio n. 19
0
 def delete(self, name):
     keychain.delete_password(table(), name)
     return
Esempio n. 20
0
 def __delitem__(self, key):
     for service in keychain.get_services():
         if key in service:
             keychain.delete_password(DB_NAME, key)