rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
error = _("Can't save shares, '%s', reported error: %s" % (sharesfile, msg) )
error = _("Can't save shares, '%s', reported error: %s" % (self.user, msg) )
def OnSave(self, widget): configdir, config = os.path.split(self.frame.np.config.filename) sharesdir = os.path.abspath(configdir+os.sep+"usershares"+os.sep) try: if not os.path.exists(sharesdir): os.mkdir(sharesdir) except Exception, msg: error = _("Can't create directory '%s', reported error: %s" % (sharesdir, msg)) ...
self.searchid = 0
self.searchid = int(random.random() * (2**31-1))
def __init__(self, frame): self.frame = frame self.interval = 0 self.searchid = 0 self.searches = {} self.timer = None self.disconnected = 0 frame.SearchNotebook.popup_enable() #frame.combo1.disable_activate() items = self.frame.np.config.sections["searches"]["history"] templist = [] for i in items: if i not in templ...
self.searchid += 1
self.searchid = (self.searchid + 1) % (2**31)
def SetInterval(self, msg): self.interval = 1000 if not self.disconnected: for term in self.frame.np.config.sections["server"]["autosearch"]: self.CreateTab(self.searchid, term, 0, 1) self.searchid += 1 self.OnAutoSearch() self.timer = gobject.timeout_add(self.interval*1000, self.OnAutoSearch)
model, iter = self.frame.UserList.get_selection().get_selected() if not iter: return
items = self.popup_menu.get_children() d = self.frame.UserList.get_path_at_pos(int(event.x), int(event.y))
def OnPopupMenu(self, widget, event): model, iter = self.frame.UserList.get_selection().get_selected() if not iter: return
user = model.get_value(iter, 1) if event.button != 3: if event.type == gtk.gdk._2BUTTON_PRESS: self.frame.privatechats.SendMessage(user, None, 1) self.frame.notebook1.set_current_page(1) return self.popup_menu.set_user(user) items = self.popup_menu.get_children() items[6].set_active(user in self.frame.np.config.se...
if d: path, column, x, y = d user = self.frame.UserList.get_model().get_value(self.frame.UserList.get_model().get_iter(path), 1) if event.button != 3: if event.type == gtk.gdk._2BUTTON_PRESS: self.frame.privatechats.SendMessage(user, None, 1) self.frame.notebook1.set_current_page(1) return self.popup_menu.set_user(us...
def OnPopupMenu(self, widget, event): model, iter = self.frame.UserList.get_selection().get_selected() if not iter: return
if self.users.has_key(user): self.users[user].conn = user+str(1234) self.frame.np.queue.put(slskmessages.GetUserStats(user)) else: w = self.subwindow(self, user, user+str(1234)) self.append_page(w.Main, user[:15], w.OnClose) self.users[user] = w self.frame.np.queue.put(slskmessages.GetUserStatus(user)) self.frame.np.qu...
self.InitWindow(user, None)
def ShowLocalInfo(self, user, descr, has_pic, pic, totalupl, queuesize, slotsavail): if self.users.has_key(user): self.users[user].conn = user+str(1234) self.frame.np.queue.put(slskmessages.GetUserStats(user)) else: w = self.subwindow(self, user, user+str(1234)) self.append_page(w.Main, user[:15], w.OnClose) self.users...
except TypeError:
del pic, loader gc.collect() except TypeError, e:
def ShowLocalInfo(self, user, descr, has_pic, pic, totalupl, queuesize, slotsavail): self.conn = None self._descr = descr buffer = self.descr.get_buffer() buffer.set_text(self.frame.np.decode(descr, self.encoding)) self.uploads.set_text(_("Total uploads allowed: %i") % totalupl) self.queuesize.set_text(_("Queue size:...
except:
except Exception, e:
def ShowLocalInfo(self, user, descr, has_pic, pic, totalupl, queuesize, slotsavail): self.conn = None self._descr = descr buffer = self.descr.get_buffer() buffer.set_text(self.frame.np.decode(descr, self.encoding)) self.uploads.set_text(_("Total uploads allowed: %i") % totalupl) self.queuesize.set_text(_("Queue size:...
return [["Latin", 'ascii'], ["US-Canada", 'cp037'], ['Hebrew', 'cp424'], ['US English', 'cp437'], ['International', 'cp500'], ['Greek', 'cp737'], ['Estonian', 'cp775'], ['Western European', 'cp850'], ['Central European', 'cp852'], ['Cyrillic', 'cp855'], ['Cyrillic', 'cp856'], ['Turkish', 'cp857'], ['Portuguese', 'cp86...
return [["Latin", 'ascii'], ["US-Canada", 'cp037'], ['Hebrew', 'cp424'], ['US English', 'cp437'], ['International', 'cp500'], ['Greek', 'cp737'], ['Estonian', 'cp775'], ['Western European', 'cp850'], ['Central European', 'cp852'], ['Cyrillic', 'cp855'], ['Cyrillic', 'cp856'], ['Turkish', 'cp857'], ['Portuguese', 'cp86...
def getencodings(self):
self.tray_status = {"hilites" : { "rooms": [], "private": [] }, "status": "", "last": ""}
self.tray_status = {"hilites" : { "rooms": [], "private": [] }, "status": "disconnect", "last": ""}
def on_delete_event(widget, event): if self.HAVE_TRAYICON: option = Option_Box(self, title=_('Close Nicotine-Plus?'), message=_('Are you sure you wish to exit Nicotine-Plus at this time?'), option1=_("Exit"), option2=_("Send to Tray"), option3=_("Cancel") ) else: option = Option_Box(self, title=_('Close Nicotine-Plus?'...
if not self.HAVE_TRAYICON: return if self.trayicon_module == None: return if self.TRAYICON_CREATED:
if not self.HAVE_TRAYICON or self.trayicon_module == None or self.TRAYICON_CREATED:
def draw_trayicon(self): if not self.HAVE_TRAYICON: return if self.trayicon_module == None: return if self.TRAYICON_CREATED: return self.TRAYICON_CREATED = 1 self.is_mapped = 1 self.trayicon = self.trayicon_module.TrayIcon("Nicotine") self.eventbox = gtk.EventBox() img = gtk.Image() self.traymenu() self.load_image(sel...
if not self.HAVE_TRAYICON: return if self.trayicon_module == None: return if not self.TRAYICON_CREATED:
if not self.HAVE_TRAYICON or self.trayicon_module == None or not self.TRAYICON_CREATED:
def load_image(self, status=None): # Abort if Trayicon module wasn't loaded if not self.HAVE_TRAYICON: return if self.trayicon_module == None: return if not self.TRAYICON_CREATED: return try: if status != None: self.tray_status["status"] = status # Check for hilites, and display hilite icon if there is a room or privat...
curtime = time.time() for i in conns.keys()[:]: if i is not s: if curtime - conns[i].lastactive > 120: self._ui_callback([ConnClose(i,conns[i].addr)]) i.close() del conns[i] else: if curtime - conns[s].lastping > 120: conns[s].lastping = curtime queue.put(ServerPing())
def run(self):
self.OnDownloadFiles(widget, dir)
for dirs in dir: self.OnDownloadFiles(widget, dirs) break
def OnDownloadFilesTo(self, widget): dir = ChooseDir(self.frame.MainWindow, self.frame.np.config.sections["transfers"]["downloaddir"]) if dir is None: return self.OnDownloadFiles(widget, dir)
major, minor, micro = [int(i) for i in s[:3)]]
major, minor, micro = [int(i) for i in s[:3]]
def makeversion(version): build = 255 if version.find("pre") >= 0: ix = version.find("pre") build = int(version[ix+3:]) version = version[:ix] elif version.find("rc") >= 0: ix = version.find("rc") build = int(version[ix+2:]) + 0x80 version = version[:ix] s = version.split(".") if len(s) >= 4: major, minor, micro, milli...
sharesfile = bz2.BZ2File(self.encode(os.path.join(sharesdir, self.user)), 'w' )
sharesfile = bz2.BZ2File(os.path.join(sharesdir, self.encode(self.user)), 'w' )
def OnSave(self, widget): configdir, config = os.path.split(self.frame.np.config.filename) sharesdir = os.path.abspath(configdir+os.sep+"usershares"+os.sep) try: if not os.path.exists(sharesdir): os.mkdir(sharesdir) except Exception, msg: error = _("Can't create directory '%s', reported error: %s" % (sharesdir, msg)) ...
f=open(self.config.sections["userinfo"]["pic"],'r')
f=open(self.config.sections["userinfo"]["pic"],'rb')
def UserInfoRequest(self, msg):
items[5].set_active(user in [i[0] for i in self.np.config.sections["server"]["userlist"]]) items[6].set_active(user in self.np.config.sections["server"]["banlist"]) items[7].set_active(user in self.np.config.sections["server"]["ignorelist"])
items[7].set_active(user in [i[0] for i in self.np.config.sections["server"]["userlist"]]) items[8].set_active(user in self.np.config.sections["server"]["banlist"]) items[9].set_active(user in self.np.config.sections["server"]["ignorelist"])
def OnPopupRUMenu(self, widget, event): items = self.ru_popup_menu.get_children() d = self.RecommendationUsersList.get_path_at_pos(int(event.x), int(event.y)) if not d: return path, column, x, y = d user = self.recommendationuserslist.get_value(self.recommendationuserslist.get_iter(path), 1) if event.button != 3: if ev...
self.title["length"] = output
self.title["album"] = output
def amarok(self): slist = self.NPFormat.child.get_text() if "$n" in slist: output = self.amarok_command("nowPlaying") if output: self.title["nowplaying"] = output if "$t" in slist: output = self.amarok_command("title") if output: self.title["title"] = output if "$l" in slist: output = self.amarok_command("totalTime") ...
def getModuleNameFromLine(word, line, column): match = sre.findall(r'(?:[a-z_][a-zA-Z0-9_]*\.)+'+word, line[:column]) if not match: return None result = match[-1][:-len("."+word)] return result
def testGetModuleNameFromLine(self): self.assertEqual("something.getopt", pythonCompletion.getModuleNameFromLine(word="err", line=" except something.getopt.err, msg:", column=36)) self.assertEqual("right.module", pythonCompletion.getModuleNameFromLine(word="word", line=" wrong.module.word module.word.in...
def getModuleNameFromLine(word, line, column): # Take part of the line until column to make sure we don't get any matches after that. match = sre.findall(r'(?:[a-z_][a-zA-Z0-9_]*\.)+'+word, line[:column]) if not match: # We're not completing a modulename, so we return None return None # To be sure it's the right match,...
def getSuggestionListModule(word, module): try: moduleDir = dir(__import__(module)) except ImportError: return [] matches = [] for elem in moduleDir: if elem.startswith(word): matches.append(elem) return matches
def testGetSuggestionListFile(self): self.assertEqual(["getSuggestionListFile", "getSuggestionListModule"], pythonCompletion.getSuggestionListFile(word="getSug", filename="pythonCompletion.py")) self.assertEqual([], pythonCompletion.getSuggestionListFile(word="foobarsomethingsomething", filename="pythonCompletion.py"))...
def getSuggestionListModule(word, module): try: moduleDir = dir(__import__(module)) except ImportError: return [] matches = [] for elem in moduleDir: if elem.startswith(word): matches.append(elem) return matches
def getSuggestionListFile(word, filename): try: f = file(filename, 'r') except IOError: return [] pattern = sre.compile(word+r'.*?\b') matches = [] for line in f.readlines(): for match in pattern.findall(line): if match != word and match not in matches: matches.append(match) matches.sort() return matches def complete(...
if __name__ == '__main__': unittest.main()
def getSuggestionListFile(word, filename): try: f = file(filename, 'r') except IOError: return [] pattern = sre.compile(word+r'.*?\b') matches = [] for line in f.readlines(): for match in pattern.findall(line): if match != word and match not in matches: matches.append(match) matches.sort() return matches
if not moduleName:
if not moduleName or moduleName == "self":
def complete(word, line, column, filename=None): moduleName = getModuleNameFromLine(word, line, column) if not moduleName: return getSuggestionListFile(word=word, filename=filename) return getSuggestionListModule(word, moduleName)
return getSuggestionListModule(word, moduleName)
else: matches = getSuggestionListModule(word, moduleName) if not matches: return getSuggestionListFile(word=word, filename=filename) else: return matches
def complete(word, line, column, filename=None): moduleName = getModuleNameFromLine(word, line, column) if not moduleName: return getSuggestionListFile(word=word, filename=filename) return getSuggestionListModule(word, moduleName)
match = sre.findall(r'(?:[a-z_][a-zA-Z0-9_]*\.)+'+word, line[:column])
match = sre.findall(r'(?:[a-zA-Z0-9_]*\.)+'+word, line[:column])
def getModuleNameFromLine(word, line, column): # Take part of the line until column to make sure we don't get any matches after that. match = sre.findall(r'(?:[a-z_][a-zA-Z0-9_]*\.)+'+word, line[:column]) if not match: # We're not completing a modulename, so we return None return None # To be sure it's the right match,...
print >>sys.stderr, str(err.msg) print >>sys.stderr, "\t for help use --help"
def main(argv=None): if argv is None: argv = sys.argv try: try: opts, args = getopt.getopt(argv[1:], "hw:l:c:f:", ["help","output=","word=","line=","column=","filename="]) except getopt.error, msg: raise Usage(msg) # option processing tmColumn = None tmLine = None tmWord = None tmFilename = None for option, value in o...
name = chooser.get_filename() db_name = os.path.basename(chooser.get_filename())
def ImportDialog(widgetTree, windows_title): import shutil chooser = gtk.FileChooserDialog(title=windows_title,action=gtk.FILE_CHOOSER_ACTION_SAVE, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)) r = chooser.run() #name of file to export name = chooser.get_filename() db_name = os.path.ba...
config_opts['basedir'] = '/var/lib/mach/roots/' config_opts['chroot'] = '/usr/sbin/mach-helper chroot' config_opts['mount'] = '/usr/sbin/mach-helper mount' config_opts['umount'] = '/usr/sbin/mach-helper umount' config_opts['rm'] = '/usr/sbin/mach-helper rm' config_opts['mknod'] = '/usr/sbin/mach-helper mknod' config_op...
config_opts['basedir'] = '/var/lib/mock/' config_opts['chroot'] = '/usr/sbin/mock-helper chroot' config_opts['mount'] = '/usr/sbin/mock-helper mount' config_opts['umount'] = '/usr/sbin/mock-helper umount' config_opts['rm'] = '/usr/sbin/mock-helper rm' config_opts['mknod'] = '/usr/sbin/mock-helper mknod' config_opts['yu...
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
def do_run_cmd(config_opts, cmd, raw_chroot=0):
def do_run_cmd(config_opts, cmd, env='', raw_chroot=0):
def do_run_cmd(config_opts, cmd, raw_chroot=0): my = Root(config_opts) my.debug("executing: %s" % cmd) my._mount() if raw_chroot: cmd = '%s %s %s' % (config_opts['chroot'], my.rootdir, cmd) os.system(cmd) else: my.do_chroot(cmd, True) my.close() my.debug('finished chroot command')
cmd = '%s %s %s' % (config_opts['chroot'], my.rootdir, cmd)
cmd = '%s %s %s %s' % (env, config_opts['chroot'], my.rootdir, cmd)
def do_run_cmd(config_opts, cmd, raw_chroot=0): my = Root(config_opts) my.debug("executing: %s" % cmd) my._mount() if raw_chroot: cmd = '%s %s %s' % (config_opts['chroot'], my.rootdir, cmd) os.system(cmd) else: my.do_chroot(cmd, True) my.close() my.debug('finished chroot command')
os.environ['PS1'] = "mock-chroot> " do_run_cmd(config_opts, "/bin/bash", raw_chroot=1)
do_run_cmd(config_opts, "/bin/bash", env='PS1="mock-chroot> "', raw_chroot=1)
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
raise YumError, "Error peforming yum command: %s" % command
raise YumError, "Error performing yum command: %s" % command
def yum(self, cmd): """use yum to install packages/package groups into the chroot""" # mock-helper yum --installroot=rootdir cmd basecmd = '%s --installroot %s' % (self.config['yum'], self.rootdir) self._mount() # check it again command = '%s %s' % (basecmd, cmd) self.debug("yum: command %s" % command)
self._mounted = 0
def __init__(self, config): self._state = 'unstarted' self.tmplog = LogBuffer() self.config = config
self._mount()
self._mountall()
def yum(self, cmd): """use yum to install packages/package groups into the chroot""" # mock-helper yum --installroot=rootdir cmd basecmd = '%s --installroot %s' % (self.config['yum'], self.rootdir) self._mount() # check it again command = '%s %s' % (basecmd, cmd) self.debug("yum: command %s" % command)
self._mount()
self._mountall()
def install_build_deps(self, srpm): """take an srpm, install it, rebuild it to srpm, return chroot-local path to the resulting srpm""" self._mount() # check it again bd_out = '%s%s' % (self.rootdir, self.builddir) # init build_dir self._build_dir_setup() # copy srpm into chroot srpmfn = os.path.basename(srpm) dest = ...
self._umount_by_file()
self._umountall()
def close(self): """unmount things and clean up a bit""" self.root_log("Cleaning up...") self.state("ending") self._umount_by_file() self._build_log.close() self.state("done") self.root_log("Done.") self._root_log.close()
def _mount(self): """mount proc and devpts into chroot"""
def _mount(self, type, device, path): "mount a device, given a filesystem type and a path" mntpath = os.path.join(self.rootdir, path) self._ensure_dir(mntpath) self.debug("mounting %s as %s" % (device, mntpath)) command = '%s -n -t %s %s %s' % (self.config['mount'], type, device, mntpath)
def _mount(self): """mount proc and devpts into chroot""" mf = os.path.join(self.statedir, 'mounted-locations') track = open(mf, 'w+')
track = open(mf, 'w+') procdir = os.path.join(self.rootdir, 'proc') self._ensure_dir(procdir) self.debug("mounting proc in %s" % procdir) command = '%s -n -t proc proc %s/proc' % (self.config['mount'], self.rootdir) track.write('proc\n')
def _mount(self): """mount proc and devpts into chroot""" mf = os.path.join(self.statedir, 'mounted-locations') track = open(mf, 'w+')
track.flush()
def _mount(self): """mount proc and devpts into chroot""" mf = os.path.join(self.statedir, 'mounted-locations') track = open(mf, 'w+')
error("could not mount proc error was: %s" % output) devptsdir = os.path.join(self.rootdir, 'dev/pts') self._ensure_dir(devptsdir) self.debug("mounting devpts in %s" % devptsdir) command = '%s -n -t devpts devpts %s' % (self.config['mount'], devptsdir) track.write('dev/pts\n') (retval, output) = self.do_elevated(com...
estr = "could not mount %s. Error was: %s" % (path, output) error(estr) raise RootError, estr track = open(mf, 'w+') track.write('%s\n' % path)
def _mount(self): """mount proc and devpts into chroot""" mf = os.path.join(self.statedir, 'mounted-locations') track = open(mf, 'w+')
if retval != 0: if output.find('already mounted') == -1: raise RootError, "could not mount /dev/pts error was: %s" % output
def _mountall(self): """mount proc, sys and devpts into chroot""" if self._mounted: return self._mount('proc', 'proc', 'proc') self._mount('devpts', 'dev/pts', 'dev/pts') if os.uname()[2].find('2.6') == 0: self._mount('sysfs', 'sys', 'sys') self._mounted = 1
def _mount(self): """mount proc and devpts into chroot""" mf = os.path.join(self.statedir, 'mounted-locations') track = open(mf, 'w+')
def _umount_by_file(self):
def _umountall(self): "undo the results of _mountall (umount proc,sys, and dev/pts)"
def _umount_by_file(self): mf = os.path.join(self.statedir, 'mounted-locations') if not os.path.exists(mf): return track = open(mf, 'r') lines = track.readlines() track.close() for item in lines: item = item.replace('\n','') if len(item.strip()) < 1: continue self.elevate() self._umount(item) self.drop() # poof, n...
item = item.replace('\n','') if len(item.strip()) < 1:
item = item.strip() if len(item) < 1:
def _umount_by_file(self): mf = os.path.join(self.statedir, 'mounted-locations') if not os.path.exists(mf): return track = open(mf, 'r') lines = track.readlines() track.close() for item in lines: item = item.replace('\n','') if len(item.strip()) < 1: continue self.elevate() self._umount(item) self.drop() # poof, n...
self.elevate()
def _umount_by_file(self): mf = os.path.join(self.statedir, 'mounted-locations') if not os.path.exists(mf): return track = open(mf, 'r') lines = track.readlines() track.close() for item in lines: item = item.replace('\n','') if len(item.strip()) < 1: continue self.elevate() self._umount(item) self.drop() # poof, n...
self.drop()
def _umount_by_file(self): mf = os.path.join(self.statedir, 'mounted-locations') if not os.path.exists(mf): return track = open(mf, 'r') lines = track.readlines() track.close() for item in lines: item = item.replace('\n','') if len(item.strip()) < 1: continue self.elevate() self._umount(item) self.drop() # poof, n...
self._mount()
self._mountall()
def _prep_install(self): """prep chroot for installation""" # make chroot dir # make /dev, mount /proc # for item in [self.basedir, self.rootdir, self.statedir, self.resultdir, os.path.join(self.rootdir, 'var/lib/rpm'), os.path.join(self.rootdir, 'var/log'), os.path.join(self.rootdir, 'dev'), os.path.join(self.rootdir,...
self._mount()
self._mountall()
def _prep_build(self): """prep the chroot for building packages""" self._make_our_user() self._build_dir_setup() self._mount() # check it again
usage: mock [options] /path/to/srpm optional commands:
usage: mock [options] [rebuild] /path/to/srpm(s) mock [options] chroot <cmd> mock [options] {init|clean|shell} commands: rebuild - build the specified SRPM(s) [default command]
def command_parse(): """return options and args from parsing the command line""" usage = """ usage: mock [options] /path/to/srpm optional commands: chroot - run the specified command within the chroot clean - clean out the specified chroot init - initialize the chroot, do not build anything""" parser = OptionParser(us...
my._mount()
my._mountall()
def do_run_cmd(config_opts, cmd, env='', raw_chroot=0): my = Root(config_opts) my.debug("executing: %s" % cmd) my._mount() if raw_chroot: cmd = '%s %s %s %s' % (env, config_opts['chroot'], my.rootdir, cmd) os.system(cmd) else: my.do_chroot(cmd, True) my.close() my.debug('finished chroot command')
my.debug('finished chroot command')
my.debug('finished: %s' % cmd)
def do_run_cmd(config_opts, cmd, env='', raw_chroot=0): my = Root(config_opts) my.debug("executing: %s" % cmd) my._mount() if raw_chroot: cmd = '%s %s %s %s' % (env, config_opts['chroot'], my.rootdir, cmd) os.system(cmd) else: my.do_chroot(cmd, True) my.close() my.debug('finished chroot command')
parser.add_option("--setpgrp", action ="store_true", dest="setpgrp", default=False, help="starts a new process group for mock")
def command_parse(): """return options and args from parsing the command line""" usage = """ usage: mock [options] /path/to/srpm optional commands: clean - clean out the specified chroot init - initialize the chroot, do not build anything""" parser = OptionParser(usage=usage, version=__VERSION__) parser.add_option("-r...
if options.setpgrp: os.setpgrp()
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
basedir = config['basedir']
root = config['root']
def __init__(self, config): self._state = 'unstarted' self.tmplog = [] self.config = config basedir = config['basedir'] if config.has_key('unique-ext'): basedir = "%s-%s" % (config['basedir'], config['unique-ext']) self.basedir = os.path.join(basedir, config['root']) self.target_arch = config['target_arch'] self.rootdi...
basedir = "%s-%s" % (config['basedir'], config['unique-ext']) self.basedir = os.path.join(basedir, config['root'])
root = "%s-%s" % (root, config['unique-ext']) self.basedir = os.path.join(config['basedir'], root)
def __init__(self, config): self._state = 'unstarted' self.tmplog = [] self.config = config basedir = config['basedir'] if config.has_key('unique-ext'): basedir = "%s-%s" % (config['basedir'], config['unique-ext']) self.basedir = os.path.join(basedir, config['root']) self.target_arch = config['target_arch'] self.rootdi...
exceptions.Exception.__init__(self)
Exception.__init__(self)
def __init__(self, msg): exceptions.Exception.__init__(self) self.msg = msg self.resultcode = 1
Error.__init__(self)
Error.__init__(self, msg)
def __init__(self, msg): Error.__init__(self) self.msg = msg self.resultcode = 30
Error.__init__(self)
Error.__init__(self, msg)
def __init__(self, msg): Error.__init__(self) self.msg = msg self.resultcode = 40
Error.__init__(self)
Error.__init__(self, msg)
def __init__(self, msg): Error.__init__(self) self.msg = msg self.resultcode = 10
Error.__init__(self)
Error.__init__(self, msg)
def __init__(self, msg): Error.__init__(self) self.msg = msg self.resultcode = 20
hdr = rpmUtils.miscutils.hdrFromPackage(ts, srpm)
try: hdr = rpmUtils.miscutils.hdrFromPackage(ts, srpm) except rpmUtils.RpmUtilsError, e: error("Specified srpm %s cannot be found/opened" % srpm) sys.exit(50)
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
buildreqs = self._text_requires_from_hdr(hdr)
buildreqs = self._text_requires_from_hdr(hdr, srpm)
def install_build_deps(self, srpm): """take an srpm, install it, rebuild it to srpm, return chroot-local path to the resulting srpm""" self._mount() # check it again bd_out = '%s%s' % (self.rootdir, self.builddir) # init build_dir self._build_dir_setup() # copy srpm into chroot srpmfn = os.path.basename(srpm) dest = ...
def _text_requires_from_hdr(self, hdr):
def _text_requires_from_hdr(self, hdr, srpm):
def _text_requires_from_hdr(self, hdr): """take a header and hand back a unique'd list of the requires as strings""" reqlist = [] names = hdr[rpm.RPMTAG_REQUIRENAME] flags = hdr[rpm.RPMTAG_REQUIREFLAGS] ver = hdr[rpm.RPMTAG_REQUIREVERSION] if names is not None: tmplst = zip(names, flags, ver) for (n, f, v) in tmplst:...
def main(): member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1) if os.geteuid() == 0: error("Don't try to run mock as root!") sys.e...
def setup_default_config_opts(config_opts):
def command_parse(): """return options and args from parsing the command line""" usage = """ usage: mock [options] /path/to/srpm optional commands: clean - clean out the specified chroot init - initialize the chroot, do not build anything""" parser = OptionParser(usage=usage, version=__VERSION__) parser.add_option("-r...
if options.arch: config_opts['target_arch'] = options.arch if options.dirty: config_opts['clean'] = False else: config_opts['clean'] = True config_opts['debug'] = options.debug config_opts['quiet'] = options.quiet if options.resultdir: config_opts['resultdir'] = options.resultdir if options.statedir: config_opts['s...
set_config_opts_per_cmdline(config_opts, options)
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
try: my = None my = Root(config_opts) except Error, e: print e if my: my.close() sys.exit(100) my.close() print 'Finished cleaning root'
do_clean(config_opts, init=0)
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
try: my = None my = Root(config_opts) my.prep() except Error, e: print e if my: my.close() sys.exit(100) my.close() print 'Finished initializing root'
do_clean(config_opts, init=1)
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
my = Root(config_opts)
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
my.debug("executing: %s" % cmd) my._mount() my.do_chroot(cmd, True) my.close() my.debug('finished chroot command')
do_run_cmd(config_opts, cmd, raw_chroot=0)
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
my = Root(config_opts) cmd = "PS1='mock-chroot> ' %s %s /bin/bash" % (config_opts['chroot'], my.rootdir) my.debug("executing: %s" % cmd) my._mount() ret = os.system(cmd) my.close() my.debug("finished shell with retval %d" % ret)
os.environ['PS1'] = "mock-chroot> " do_run_cmd(config_opts, "/bin/bash", raw_chroot=1)
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
for srpm in srpms: ts = rpmUtils.transaction.initReadOnlyTransaction() try: hdr = rpmUtils.miscutils.hdrFromPackage(ts, srpm) except rpmUtils.RpmUtilsError, e: error("Specified srpm %s cannot be found/opened" % srpm) sys.exit(50) if hdr[rpm.RPMTAG_SOURCEPACKAGE] != 1: error("Specified srpm isn't a srpm! Can't go on")...
ensure_filetype_srpm(srpms) do_rebuild(config_opts, srpms)
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
cmd = '%s -rf %s' % (self.config['rm'], self.basedir)
cmd = '%s -rfv %s' % (self.config['rm'], self.basedir)
def clean(self): """clean out chroot with extreme prejudice :)""" self.state("clean")
cmd = 'rm -rf %s' % self.builddir
cmd = 'rm -rfv %s' % self.builddir
def _build_dir_setup(self): # purge the builddir, if it exists bd_out = '%s%s' % (self.rootdir, self.builddir) if os.path.exists(bd_out): cmd = 'rm -rf %s' % self.builddir self.do_chroot(cmd, fatal=True) # create dir structure for subdir in ('RPMS', 'SRPMS', 'SOURCES', 'SPECS', 'BUILD', 'originals'): cmd = "mkdir -p %...
srpm = args[1]
srpms = args[1:]
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
srpm = args[0] ts = rpmUtils.transaction.initReadOnlyTransaction()
srpms = args[0:] for srpm in srpms: ts = rpmUtils.transaction.initReadOnlyTransaction() try: hdr = rpmUtils.miscutils.hdrFromPackage(ts, srpm) except rpmUtils.RpmUtilsError, e: error("Specified srpm %s cannot be found/opened" % srpm) sys.exit(50) if hdr[rpm.RPMTAG_SOURCEPACKAGE] != 1: error("Specified srpm isn't a sr...
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
hdr = rpmUtils.miscutils.hdrFromPackage(ts, srpm) except rpmUtils.RpmUtilsError, e: error("Specified srpm %s cannot be found/opened" % srpm) sys.exit(50) if hdr[rpm.RPMTAG_SOURCEPACKAGE] != 1: error("Specified srpm isn't a srpm! Can't go on") sys.exit(50) try: my = None
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
my.prep() my.build(srpm)
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
for srpm in srpms: try: my.prep() my.build(srpm) except Error, e: error(e) if my: my.close() sys.exit(e.resultcode)
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
help="path for state dirresulting files to be put")
help="path for state file is written")
def command_parse(): """return options and args from parsing the command line""" usage = """ usage: mock [options] /path/to/srpm optional commands: clean - clean out the specified chroot init - initialize the chroot, do not build anything""" parser = OptionParser(usage=usage, version=__VERSION__) parser.add_option("-r...
cmd = '%s -rfv %s' % (self.config['rm'], self.basedir) (retval, output) = self.do(cmd) if retval != 0: error("Errors cleaning out chroot: %s" % output) if os.path.exists(self.rootdir) or os.path.exists(self.statedir): raise Error, "Failed to clean basedir, exiting"
if os.path.exists(self.basedir) cmd = '%s -rfv %s' % (self.config['rm'], self.basedir) (retval, output) = self.do(cmd) if retval != 0: error("Errors cleaning out chroot: %s" % output) if os.path.exists(self.rootdir) or os.path.exists(self.statedir): raise Error, "Failed to clean basedir, exiting"
def clean(self): """clean out chroot with extreme prejudice :)""" self.root_log('Cleaning Root') if os.path.exists('%s/%s' % (self.rootdir, 'proc')): self._umount('proc') if os.path.exists('%s/%s' % (self.rootdir, 'dev/pts')): self._umount('dev/pts') cmd = '%s -rfv %s' % (self.config['rm'], self.basedir) (retval, outp...
my.close()
if my: my.close()
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
if os.path.exists(self.basedir)
if os.path.exists(self.basedir):
def clean(self): """clean out chroot with extreme prejudice :)""" self.root_log('Cleaning Root') if os.path.exists('%s/%s' % (self.rootdir, 'proc')): self._umount('proc') if os.path.exists('%s/%s' % (self.rootdir, 'dev/pts')): self._umount('dev/pts') if os.path.exists(self.basedir) cmd = '%s -rfv %s' % (self.config['r...
cmd = 'groupinstall %s' % self.config['buildgroup']
cmd = 'install %s' % self.config['chroot_dep_package']
def prep(self): self.state("prep") self.log("This may take a while") self._prep_install() if self.config['clean']: cmd = 'groupinstall %s' % self.config['buildgroup'] else: cmd = 'update'
config_opts['buildgroup'] = 'build'
config_opts['chroot_dep_package'] = 'buildsys-build'
def main(): # before we go on, make sure the user is a member of the 'mock' group. member = False for item in os.getgroups(): try: grptup = grp.getgrgid(item) except KeyError, e: continue if grptup[0] == 'mock': member = True if not member: print "You need to be a member of the mock group for this to work" sys.exit(1)...
create_cache=0 if self.config['use_cache']: cache_exists = os.path.exists( self.cache_file ) if cache_exists: cache_mtime = os.stat(self.cache_file)[stat.ST_MTIME] cache_age_days = (time.time() - cache_mtime) / (60 * 60 * 24) if cache_age_days > self.config['max_cache_age_days']: self.config["rebuild_cache"] = True if...
def prep(self): self.state("prep") self.log("This may take a while") self._prep_install() if self.config['clean']: cmd = '%s' % self.config['chroot_setup_cmd'] else: cmd = 'update'
if self.config['clean']: cmd = '%s' % self.config['chroot_setup_cmd'] else: cmd = 'update'
def prep(self): self.state("prep") self.log("This may take a while") self._prep_install() if self.config['clean']: cmd = '%s' % self.config['chroot_setup_cmd'] else: cmd = 'update'
if create_cache: self.pack()
def prep(self): self.state("prep") self.log("This may take a while") self._prep_install() if self.config['clean']: cmd = '%s' % self.config['chroot_setup_cmd'] else: cmd = 'update'
cmd = "chown %s.%s %s" % (self.config['chrootuser'], self.config['chrootgroup'], "%s" % key)
cmd = "chown %s.%s %s" % (self.config['chrootuid'], self.config['chrootgid'], "%s" % key)
def _prep_install(self): """prep chroot for installation""" # make chroot dir # make /dev, mount /proc # for item in [self.basedir, self.rootdir, self.statedir, self.resultdir, os.path.join(self.rootdir, 'var/lib/rpm'), os.path.join(self.rootdir, 'var/log'), os.path.join(self.rootdir, 'dev'), os.path.join(self.rootdir,...
if not os.path.exists(os.path.join(self.rootdir, 'usr/sbin/useradd')): raise RootError, "Could not find useradd in chroot, maybe the install failed?"
need_add_user = 1 else: curruid = self.config['chrootuid'] chrootuid = None passwd = os.path.join(self.rootdir, 'etc', 'passwd') fd = open( passwd, "r" ) while 1: line = fd.readline() if line == "": break if line.startswith(self.config["chrootuser"]): chrootuid = int(line.split(":")[2]) if chrootuid is not None...
def _make_our_user(self): # should check if the user exists first # make the buildusers/groups if not os.path.exists(self.rootdir + self.homedir): if not os.path.exists(os.path.join(self.rootdir, 'usr/sbin/useradd')): raise RootError, "Could not find useradd in chroot, maybe the install failed?" cmd = '/usr/sbin/userad...
parser.add_option("--no-clean", action ="store_true", dest="dirty", help="do not clean chroot before building")
parser.add_option("--no-clean", action ="store_false", dest="clean", help="do not clean chroot before building", default=True)
def command_parse(): """return options and args from parsing the command line""" usage = """ usage: mock [options] /path/to/srpm optional commands: clean - clean out the specified chroot init - initialize the chroot, do not build anything""" parser = OptionParser(usage=usage, version=__VERSION__) parser.add_option("-r...
if options.dirty: config_opts['clean'] = False else: config_opts['clean'] = True
config_opts['clean'] = options.clean
def set_config_opts_per_cmdline(config_opts, options): # do some other options and stuff if options.arch: config_opts['target_arch'] = options.arch if options.dirty: config_opts['clean'] = False else: config_opts['clean'] = True config_opts['debug'] = options.debug config_opts['quiet'] = options.quiet if options.res...
cmd = "%s -c 'rpmbuild --rebuild --target %s --nodeps %s' %s" % (
cmd = "cd /;%s -c 'rpmbuild --rebuild --target %s --nodeps %s' %s" % (
def build(self, srpm): """build an srpm into binary rpms, capture log""" self.state("setup")
mf = os.path.join(self.statedir, 'mounted')
mf = os.path.join(self.statedir, 'mounted-locations')
def _mount(self): """mount proc and devpts into chroot""" mf = os.path.join(self.statedir, 'mounted') track = open(mf, 'w+')
command = '%s -t devpts -o uid=%s,gid=%s devpts %s' % ( self.config['mount'], self.config['chrootuid'], self.config['chrootgid'], devptsdir)
command = '%s -t devpts devpts %s' % (self.config['mount'], devptsdir)
def _mount(self): """mount proc and devpts into chroot""" mf = os.path.join(self.statedir, 'mounted') track = open(mf, 'w+')
icon = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, gtk.TRUE, 8, 16, 16)
icon = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, TRUE, 8, 16, 16)
def load_and_scale_icon(self, path): """Helper function for loading an icon and scaling it to 16x16""" orig = gtk.gdk.pixbuf_new_from_file(path) icon = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, gtk.TRUE, 8, 16, 16) orig.scale(icon, 0, 0, 16, 16, 0, 0, 16.0/orig.get_width(), 16.0/orig.get_height(), gtk.gdk.INTERP_HYPER) re...
else:
elif device.properties["info.bus"]=="block": if device.properties.has_key("info.product"): product.set_label("%s"%device.properties["info.product"]) else: product.set_label("Unknown") if device.properties.has_key("info.vendor"): vendor.set_label("%s"%device.properties["info.vendor"]) else: vendor.set_label("Unknown") ...
def update_tab_device(self, device): """Updates the 'Device' tab given a Device object""" bus = self.xml.get_widget("ns_device_bus") #state = self.xml.get_widget("ns_device_status") vendor = self.xml.get_widget("ns_device_vendor") product = self.xml.get_widget("ns_device_name") category = self.xml.get_widget("ns_device...
return self.bus.add_signal_receiver(lambda *args: self.device_condition(udi, *args), "Condition", "org.freedesktop.Hal.Device", "org.freedesktop.Hal", udi)
def add_device_signal_recv (self, udi):
try: self.bus.remove_signal_receiver(lambda *args: self.property_modified(udi, *args), "PropertyModified", "org.freedesktop.Hal.Device", "org.freedesktop.Hal", udi) except: print "FIXME: unknown reason for the error while removing this rule from dbus" return self.bus.remove_signal_receiver(lambda *args: self.device_con...
try: self.bus.remove_signal_receiver(None, "PropertyModified", "org.freedesktop.Hal.Device", "org.freedesktop.Hal", udi) except Exception, e: print "Older versions of the D-BUS bindings have an error when removing signals. Please upgrade." print e
def remove_device_signal_recv (self, udi):
category.set_label("Unknown") capabilities.set_label("Unknown")
if device.properties.has_key("info.category"): category.set_label("%s"%device.properties["info.category"]) else: category.set_label("Unknown") if device.properties.has_key("info.capabilities"): capabilities.set_label("%s"%device.properties["info.capabilities"]) else: capabilities.set_label("Unknown")
def update_tab_device(self, device): """Updates the 'Device' tab given a Device object""" bus = self.xml.get_widget("ns_device_bus") #state = self.xml.get_widget("ns_device_status") vendor = self.xml.get_widget("ns_device_vendor") product = self.xml.get_widget("ns_device_name") category = self.xml.get_widget("ns_device...
product = device.properties["info.product"] if product=="Computer": return self.icons["computer"]
def get_icon(self, device): """Given a Device object return an icon to display"""
state = self.xml.get_widget("ns_device_status")
def update_tab_device(self, device): """Updates the 'Device' tab given a Device object""" bus = self.xml.get_widget("ns_device_bus") state = self.xml.get_widget("ns_device_status") vendor = self.xml.get_widget("ns_device_vendor") product = self.xml.get_widget("ns_device_name") category = self.xml.get_widget("ns_device_...