示例#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
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
示例#3
0
文件: commands.py 项目: jkakar/kanban
 def run(self):
     credentials_path = os.path.join(get_config_path(), "credentials.txt")
     if os.path.exists(credentials_path):
         raise RuntimeError(
             "Credentials already exist at %s" % credentials_path)
     launchpad = Launchpad.get_token_and_login(
         "kanban", SERVICE_ROOT, get_cache_path())
     launchpad.credentials.save(open(credentials_path, "w"))
示例#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
示例#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
示例#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
示例#7
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
示例#9
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
示例#11
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']
示例#12
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
示例#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
示例#14
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
示例#15
0
def manualAuthentication():
	global launchpad
	launchpad = Launchpad.get_token_and_login('Tagaini Jisho release uploader', serviceRoot, cachedir)
	launchpad.credentials.save(file(credentialsfile, 'w'))
示例#16
0
    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):
        creds = Credentials()
        creds.load(open('%s/lpcreds.txt' % CONFDIR))
        LP = Launchpad(creds, EDGE_SERVICE_ROOT, CACHEDIR)
        bug = LP.bugs[1]
        print '%s (%s) By %s' % (bug.title, bug.self_link, bug.owner)
        sys.exit(0)

    lp = Launchpad.get_token_and_login('ircbot', EDGE_SERVICE_ROOT, CACHEDIR)
    try:
        bug_one = lp.bugs[1]
    except Exception, e:
        print str(e)
        sys.exit(1)

    lp.credentials.save(file('%s/lpcreds.txt' % CONFDIR, 'w'))
    print 'Configuration successful'
示例#17
0
	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):
		creds = Credentials()
		creds.load(open('%s/lpcreds.txt' % CONFDIR))
		LP = Launchpad(creds, EDGE_SERVICE_ROOT, CACHEDIR)
		bug = LP.bugs[1]
		print '%s (%s) By %s' % (bug.title, bug.self_link, bug.owner)
		sys.exit(0)
		
	lp = Launchpad.get_token_and_login('ircbot', EDGE_SERVICE_ROOT, CACHEDIR)
	try:
		bug_one = lp.bugs[1]
	except Exception, e:
		print str(e)
		sys.exit(1)

	lp.credentials.save(file('%s/lpcreds.txt' % CONFDIR, 'w'))
	print 'Configuration successful'
示例#18
0
 def login(self):
   self.launchpad = Launchpad.get_token_and_login(self.username, self.service, self.cacheDir)
示例#19
0
    'Number of tasks that was created',
    registry=registry)

tasks_updated_counter = Counter(
    'tasks_updated_count',
    'Number of tasks that was updated',
    registry=registry)

parser = argparse.ArgumentParser()
parser.add_argument('--prometheus', type=str, help='Prometheus host to connect to.', default=None)
utils.add_calendar_arguments(parser)

flags = parser.parse_args()

launchpad = Launchpad.get_token_and_login(
        'dystros', 'production',
        os.path.join(xdg_cache_home, 'dystros'))

STATUSES = [
    'New',
    'Incomplete',
    'Confirmed',
    'Triaged',
    'In Progress',
    'Fix Committed',
    'Fix Released',
    'Won\'t Fix',
]

for task in launchpad.bugs.searchTasks(assignee=launchpad.me, status=STATUSES):
    print("Processing %s" % task.bug.id)