Exemplo n.º 1
0
def create_session():
    lplib_cachedir = os.path.expanduser("~/.cache/launchpadlib/")
    hydrazine_cachedir = os.path.expanduser("~/.cache/hydrazine/")
    rrd_dir = os.path.expanduser("~/.cache/hydrazine/rrd")
    for d in [lplib_cachedir, hydrazine_cachedir, rrd_dir]:
        if not os.path.isdir(d):
            os.makedirs(d, mode=0700)

    hydrazine_credentials_filename = os.path.join(hydrazine_cachedir,
        'credentials')
    if os.path.exists(hydrazine_credentials_filename):
        credentials = Credentials()
        credentials.load(file(
            os.path.expanduser("~/.cache/hydrazine/credentials"),
            "r"))
        trace('loaded existing credentials')
        return Launchpad(credentials, service_root,
            lplib_cachedir)
        # TODO: handle the case of having credentials that have expired etc
    else:
        launchpad = Launchpad.get_token_and_login(
            'Hydrazine',
            service_root,
            lplib_cachedir)
        trace('saving credentials...')
        launchpad.credentials.save(file(
            hydrazine_credentials_filename,
            "w"))
        return launchpad
Exemplo n.º 2
0
def create_session():
    lplib_cachedir = os.path.expanduser("~/.cache/launchpadlib/")
    hydrazine_cachedir = os.path.expanduser("~/.cache/hydrazine/")
    rrd_dir = os.path.expanduser("~/.cache/hydrazine/rrd")
    for d in [lplib_cachedir, hydrazine_cachedir, rrd_dir]:
        if not os.path.isdir(d):
            os.makedirs(d, mode=0700)

    hydrazine_credentials_filename = os.path.join(hydrazine_cachedir,
        'credentials')
    if os.path.exists(hydrazine_credentials_filename):
        credentials = Credentials()
        credentials.load(file(
            os.path.expanduser("~/.cache/hydrazine/credentials"),
            "r"))
        trace('loaded existing credentials')
        return Launchpad(credentials, service_root,
            lplib_cachedir)
        # TODO: handle the case of having credentials that have expired etc
    else:
        launchpad = Launchpad.get_token_and_login(
            'Hydrazine',
            service_root,
            lplib_cachedir)
        trace('saving credentials...')
        launchpad.credentials.save(file(
            hydrazine_credentials_filename,
            "w"))
        return launchpad
Exemplo n.º 3
0
def get_launchpad():
    """Get a Launchpad instance.

    @raise RuntimeError: Raised if credentials are not available.
    """
    credentials_path = os.path.join(get_config_path(), "credentials.txt")
    if not os.path.exists(credentials_path):
        raise RuntimeError(
            "Run the launchpad-login command to create OAuth credentials.")
    credentials = Credentials()
    credentials.load(open(credentials_path, "r"))
    return Launchpad(credentials, SERVICE_ROOT, get_cache_path())
Exemplo n.º 4
0
 def get_lp(self):
     if not os.path.isdir(self.cachedir):            
         os.makedirs(self.cachedir)
         
     if not os.path.isfile(self.credential_file):        
         launchpad = Launchpad.get_token_and_login(self.application, STAGING_SERVICE_ROOT, self.cachedir)        
         launchpad.credentials.save(file(self.credential_file, "w"))
     else:        
         credentials = Credentials()
         credentials.load(open(self.credential_file))
         launchpad = Launchpad(credentials, STAGING_SERVICE_ROOT, self.cachedir)
     return launchpad
Exemplo n.º 5
0
 def get_lp(self):
     launchpad = False
     cachedir = os.path.expanduser('~/.launchpadlib/cache')
     if not os.path.exists(cachedir):
             os.makedirs(cachedir,0700)
     credfile = os.path.expanduser('~/.launchpadlib/credentials')
     try:
             credentials = Credentials()
             credentials.load(open(credfile))
             launchpad = Launchpad(credentials, EDGE_SERVICE_ROOT, cachedir)
     except:
             launchpad = Launchpad.get_token_and_login(sys.argv[0], EDGE_SERVICE_ROOT, cachedir)
     return launchpad
Exemplo n.º 6
0
    def get_lp(self):
        if not os.path.isdir(self.cachedir):
            os.makedirs(self.cachedir)

        if not os.path.isfile(self.credential_file):
            launchpad = Launchpad.get_token_and_login(self.application,
                                                      STAGING_SERVICE_ROOT,
                                                      self.cachedir)
            launchpad.credentials.save(file(self.credential_file, "w"))
        else:
            credentials = Credentials()
            credentials.load(open(self.credential_file))
            launchpad = Launchpad(credentials, STAGING_SERVICE_ROOT,
                                  self.cachedir)
        return launchpad
Exemplo n.º 7
0
def get_launchpad():
    if not HAVE_LPLIB:
        return None
    try:
        return Launchpad.login_anonymously("bzr-builddeb",
            service_root=LPNET_SERVICE_ROOT)
    except AttributeError: # older version of launchpadlib
        creds_path = os.path.join(config_dir(), "builddeb.lp_creds.txt")
        if not os.path.exists(creds_path):
            return None
        creds = Credentials("bzr-builddeb")
        f = open(creds_path)
        try:
            creds.load(f)
        finally:
            f.close()
        return Launchpad(creds, service_root=LPNET_SERVICE_ROOT)
Exemplo n.º 8
0
 def get_lp(self):
     launchpad = False
     if not os.path.isdir(self.cachedir):
         try:
             os.makedirs(self.cachedir)
         except:
             raise 
     if not os.path.isfile(self.lp_credential_file): 
         try:       
             launchpad = Launchpad.get_token_and_login('openerp', EDGE_SERVICE_ROOT, self.cachedir)        
             launchpad.credentials.save(file(self.lp_credential_file, "w"))
         except:
             print 'Service Unavailable !'
     else:        
         credentials = Credentials()
         credentials.load(open(self.lp_credential_file))
         launchpad = Launchpad(credentials, EDGE_SERVICE_ROOT, self.cachedir)
     return launchpad
def connect():
    cachedir = os.path.expanduser('~/.launchpadlib/cache')
    if not os.path.exists(cachedir):
        os.makedirs(cachedir, 0700)

    credfile = os.path.expanduser('~/.launchpadlib/credentials')
    try:
        credentials = Credentials()
        credentials.load(open(credfile))
        launchpad = Launchpad(credentials, EDGE_SERVICE_ROOT, cachedir)
    except:
        launchpad = Launchpad.get_token_and_login(sys.argv[0],
                                                  EDGE_SERVICE_ROOT, cachedir)
        credfd = tempfile.NamedTemporaryFile(dir=os.path.dirname(credfile))
        launchpad.credentials.save(credfd)
        os.link(credfd.name, credfile)
        credfd.close()
    return launchpad
Exemplo n.º 10
0
 def get_lp(self):
     launchpad = False
     if not os.path.isdir(self.cachedir):
         try:
             os.makedirs(self.cachedir)
         except:
             raise
     if not os.path.isfile(self.lp_credential_file):
         try:
             launchpad = Launchpad.get_token_and_login(
                 'openerp', EDGE_SERVICE_ROOT, self.cachedir)
             launchpad.credentials.save(file(self.lp_credential_file, "w"))
         except:
             print 'Service Unavailable !'
     else:
         credentials = Credentials()
         credentials.load(open(self.lp_credential_file))
         launchpad = Launchpad(credentials, EDGE_SERVICE_ROOT,
                               self.cachedir)
     return launchpad
def lp_login():
        cachedir = os.path.expanduser('~/.cache/launchpadlib/')
        if not os.path.isdir(cachedir):
                os.makedirs(cachedir)
        creddir = os.path.expanduser("~/.cache/lp_credentials")
        if not os.path.isdir(creddir):
                os.makedirs(creddir)
                os.chmod(creddir, 0700)
        try:
                credfile = open(os.path.join(creddir, 'close_launchpad_bugs.txt'), 'r')
                credentials = Credentials()
                credentials.load(credfile)
                credfile.close()
                launchpad = Launchpad(credentials, EDGE_SERVICE_ROOT, cachedir)
        except IOError:
                launchpad = Launchpad.get_token_and_login('close_launchpad_bugs', EDGE_SERVICE_ROOT, cachedir)
                credfile = open(os.path.join(creddir, 'close_launchpad_bugs.txt'), 'w')
                launchpad.credentials.save(credfile)
                credfile.close()
        return launchpad
Exemplo n.º 12
0
 def login(self):
     if self.launchpad is not None:
         return
     cachedir = os.path.expanduser('~/.cache/launchpadlib')
     creddir = os.path.expanduser('~/.config/launchpadlib')
     credfile = creddir + '/credentials.txt'
     root = EDGE_SERVICE_ROOT
     if not os.path.exists(cachedir):
         os.makedirs(cachedir, 0700)
     try:
         credentials = Credentials()
         credentials.load(open(credfile))
         self.launchpad = Launchpad(credentials, root, cachedir)
     except:
         self.launchpad = Launchpad.get_token_and_login('igotu2gpx-launchpad-tools',
                 root, cachedir)
         if not os.path.exists(creddir):
             os.makedirs(creddir, 0700)
         self.launchpad.credentials.save(open(credfile, "w", 0600))
     self.project = self.launchpad.projects['igotu2gpx']
Exemplo n.º 13
0
    def launchpad(self):
        '''Return Launchpad instance.'''

        if self.__launchpad:
            return self.__launchpad

        if self.options.get('staging') or os.getenv('APPORT_STAGING'):
            launchpad_instance = STAGING_SERVICE_ROOT
        else:
            launchpad_instance = EDGE_SERVICE_ROOT

        auth_dir = os.path.dirname(self.auth)
        if auth_dir and not os.path.isdir(auth_dir):
            os.makedirs(auth_dir)

        try:
            if os.path.exists(self.auth):
                # use existing credentials
                credentials = Credentials()
                credentials.load(open(self.auth))
                self.__launchpad = Launchpad(credentials, launchpad_instance,
                                             self.__lpcache)
            else:
                # get credentials and save them
                try:
                    self.__launchpad = Launchpad.get_token_and_login(
                        'apport-collect', launchpad_instance, self.__lpcache)
                except HTTPError, e:
                    print >> sys.stderr, 'Error connecting to Launchpad: %s\nYou have to allow "Change anything" privileges.' % str(
                        e)
                    sys.exit(1)
                f = open(self.auth, 'w')
                os.chmod(self.auth, 0600)
                self.__launchpad.credentials.save(f)
                f.close()
        except (socket.error, ServerNotFoundError), e:
            print >> sys.stderr, 'Error connecting to Launchpad: %s' % str(e)
            sys.exit(99)  # transient error
Exemplo n.º 14
0
    def launchpad(self):
        '''Return Launchpad instance.'''

        if self.__launchpad:
            return self.__launchpad

        if self.options.get('staging') or os.getenv('APPORT_STAGING'):
            launchpad_instance = STAGING_SERVICE_ROOT
        else:
            launchpad_instance = EDGE_SERVICE_ROOT

        auth_dir = os.path.dirname(self.auth)
        if auth_dir and not os.path.isdir(auth_dir):
            os.makedirs(auth_dir)

        try:
            if os.path.exists(self.auth):
                # use existing credentials
                credentials = Credentials()
                credentials.load(open(self.auth))
                self.__launchpad = Launchpad(credentials, launchpad_instance,
                        self.__lpcache)
            else:
                # get credentials and save them
                try:
                    self.__launchpad = Launchpad.get_token_and_login('apport-collect',
                            launchpad_instance, self.__lpcache)
                except HTTPError, e:
                    print >> sys.stderr, 'Error connecting to Launchpad: %s\nYou have to allow "Change anything" privileges.' % str(e)
                    sys.exit(1)
                f = open(self.auth, 'w')
                os.chmod(self.auth, 0600)
                self.__launchpad.credentials.save(f)
                f.close()
        except (socket.error, ServerNotFoundError), e:
            print >> sys.stderr, 'Error connecting to Launchpad: %s' % str(e)
            sys.exit(99) # transient error
Exemplo n.º 15
0
def lp_login():
    cachedir = os.path.expanduser('~/.cache/launchpadlib/')
    if not os.path.isdir(cachedir):
        os.makedirs(cachedir)
    creddir = os.path.expanduser("~/.cache/lp_credentials")
    if not os.path.isdir(creddir):
        os.makedirs(creddir)
        os.chmod(creddir, 0o700)

    credpath = os.path.join(creddir, 'close_launchpad_bugs.txt')
    try:
        credfile = open(credpath, 'r')
        credentials = Credentials()
        credentials.load(credfile)
        credfile.close()
        launchpad = Launchpad(credentials, EDGE_SERVICE_ROOT, cachedir)
    except IOError:
        launchpad = Launchpad.get_token_and_login('close_launchpad_bugs',
                                                  EDGE_SERVICE_ROOT, cachedir)
        credfile = open(credpath, 'w')
        launchpad.credentials.save(credfile)
        credfile.close()

    return launchpad
Exemplo n.º 16
0
	finalDesc = FILE_DESCRIPTIONS[fType]
	if lang: finalDesc = finalDesc % (lang)
	try:
		releaseFile = release.add_file(filename = os.path.basename(f), description = finalDesc, file_content = open(f, 'r').read(), content_type = FILE_CONTENTTYPES[fType], file_type = FILE_TYPES[fType], signature_filename = fSign, signature_content = open(fSign, 'r').read())
	# Don't know why, but an exception will always be thrown even though the file is uploaded
	except lazr.restfulclient.errors.HTTPError:
		pass

for arg in sys.argv:
	if arg == "--auth":
		manualAuthentication()

if not launchpad:
	if os.path.exists(credentialsfile):
		credentials = Credentials()
		credentials.load(open(credentialsfile))
		launchpad = Launchpad(credentials, serviceRoot, cachedir)
	else:
		manualAuthentication()

project = launchpad.projects[projectName]
for release in project.releases:
	if release.version == lpRelease:
		gpgPass = getpass.getpass("Found the release. I will now create signature files - please enter your GPG private key passphrase: ")
		# Upload the source tarball
		if options.uploadsource: uploadFile('pack/source/tagainijisho-' + releaseVersion + '.tar.gz', 'source', '', gpgPass)
		# Upload the mac binaries
		if options.uploadmac:
			for lang in LANGUAGES:
				uploadFile('pack/MacOS/Tagaini Jisho-' + releaseVersion + '-' + LANGUAGES_SUFFIXES[lang] + '.dmg', 'mac', lang, gpgPass)
		# Upload the win32 binaries
Exemplo n.º 17
0
        bug = LP.bugs[bug_id]
    except Exception, e:
        self.msg(dst, 'Could not find lp bug %i, %s' % (bug_id, str(e)))
        return

    owner = str(bug.owner).split('~', 1)[1]
    self.msg(
        dst,
        str('LP bug #%i, %s (%s) by %s' %
            (bug_id, bug.title, bug.self_link, owner)))


# this is the module initialization process if we are imported.
if __name__ == 'lpbugs':
    creds = Credentials()
    creds.load(open('%s/lpcreds.txt' % CONFDIR))
    LP = Launchpad(creds, EDGE_SERVICE_ROOT, CACHEDIR)
    core.MODULES.append(__name__)
    log('%s Loaded Successfully' % __name__)

# This is the setup initialization process
if __name__ == '__main__':
    if not os.path.exists(CACHEDIR):
        print "Creating conf and cache dir"
        try:
            os.makedirs(CACHEDIR)
        except Exception, e:
            print 'Error creating directories, %s' % str(e)
            sys.exit(1)

    if os.path.exists('%s/lpcreds.txt' % CONFDIR):
Exemplo n.º 18
0
			str(e)
		))
		return

	owner = str(bug.owner).split('~', 1)[1]
	self.msg(dst, str('LP bug #%i, %s (%s) by %s' % (
		bug_id,
		bug.title,
		bug.self_link,
		owner
	)))

# this is the module initialization process if we are imported.
if __name__ == 'lpbugs':
	creds = Credentials()
	creds.load(open('%s/lpcreds.txt' % CONFDIR))
	LP = Launchpad(creds, EDGE_SERVICE_ROOT, CACHEDIR)
	core.MODULES.append(__name__)
	log('%s Loaded Successfully' % __name__)
	
# This is the setup initialization process
if __name__ == '__main__':
	if not os.path.exists(CACHEDIR):
		print "Creating conf and cache dir"
		try:
			os.makedirs(CACHEDIR)
		except Exception, e:
			print 'Error creating directories, %s' % str(e)
			sys.exit(1)

	if os.path.exists('%s/lpcreds.txt' % CONFDIR):
Exemplo n.º 19
0
	changelog = 'debian/changelog'

	if not os.path.exists(changelog):
		changelog = "./changelog"
		if not os.path.exists(changelog):
			print "File "+changelog+" not found"
			sys.exit(2)

	home = os.environ['HOME']
	cachedir = home + '/.launchpadlib/cache/'

	launchpad_key = home + "/.launchpadlib/key.txt"

	credentials = Credentials()
	credentials.load(open(launchpad_key))
	#launchpad = Launchpad(credentials, EDGE_SERVICE_ROOT, cachedir)
	launchpad = Launchpad.login_with('GetDeb.net Bug Manager', 'production')

	me = launchpad.me

	project_name = "GetDeb Software Portal"

	if sys.argv[1] == 'start' or sys.argv[1].startswith('s'):
		current_changelog = get_changelog(1, changelog)
		previous_changelog = get_changelog(2, changelog)

		bug_ids = current_changelog['bugs_to_be_closed']
		check_not_empty(bug_ids)

		for bug_id in bug_ids:
Exemplo n.º 20
0
    changelog = 'debian/changelog'

    if not os.path.exists(changelog):
        changelog = "./changelog"
        if not os.path.exists(changelog):
            print "File " + changelog + " not found"
            sys.exit(2)

    home = os.environ['HOME']
    cachedir = home + '/.launchpadlib/cache/'

    launchpad_key = home + "/.launchpadlib/key.txt"

    credentials = Credentials()
    credentials.load(open(launchpad_key))
    #launchpad = Launchpad(credentials, EDGE_SERVICE_ROOT, cachedir)
    launchpad = Launchpad.login_with('GetDeb.net Bug Manager', 'production')

    me = launchpad.me

    project_name = "GetDeb Software Portal"

    if sys.argv[1] == 'start' or sys.argv[1].startswith('s'):
        current_changelog = get_changelog(1, changelog)
        previous_changelog = get_changelog(2, changelog)

        bug_ids = current_changelog['bugs_to_be_closed']
        check_not_empty(bug_ids)

        for bug_id in bug_ids:
Exemplo n.º 21
0
 def authenticateFromSaved(self):
   credentials = Credentials()
   credentials.load(file(self.credentialsFilename, 'r'))
   self.launchpad = Launchpad(credentials, self.service, self.cacheDir)