bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def getSentence(self): return self.question + self.nugget_list[random.randint(0, len(self.nugget_list))]
def getSentence(self): return self.question + self.nugget_list[random.randint(0, len(self.nugget_list))]
475,100
def __init__(self, archive_num): self.question = "Did you know, " #archive_max checked 13-8-2009 self.archive_max = 246 self.archive_num = archive_num if self.archive_num > self.archive_max: self.archive_num = random.randint(1, self.archive_max) self.url = "http://en.wikipedia.org/wiki/Wikipedia:Recent_additions_" + str(self.archive_num) Nuggets.__init__(self)
def __init__(self, archive_num): self.question = "Did you know, " #archive_max checked 13-8-2009 self.archive_max = 255 self.archive_num = archive_num if self.archive_num > self.archive_max: self.archive_num = random.randint(1, self.archive_max) self.url = "http://en.wikipedia.org/wiki/Wikipedia:Recent_additions_" + str(self.archive_num) Nuggets.__init__(self)
475,101
def buildProtocol(self, address): if re.match("[^a-z]+", address.host): log.error("Kludge fix for twisted.words weirdness") fqdn = socket.getfqdn(address.host) address = (fqdn, address.port) else: address = (address.host, address.port)
def buildProtocol(self, address): if re.match("[^a-z]+", address.host): log.error("Kludge fix for twisted.words weirdness") fqdn = socket.getfqdn(address.host) address = (fqdn, address.port) else: address = (address.host, address.port)
475,102
def cb(tries): # Ack timeout callback
def cb(tries): # Ack timeout callback
475,103
def broadcastHeader(self, kind, src_ipp, hops=64, flags=0): # Build the header used for all broadcast packets packet = [kind] packet.append(self.main.osm.me.ipp) packet.append(struct.pack('!BB', hops, flags)) packet.append(src_ipp) return packet
def broadcastHeader(self, kind, src_ipp, hops=32, flags=0): # Build the header used for all broadcast packets packet = [kind] packet.append(self.main.osm.me.ipp) packet.append(struct.pack('!BB', hops, flags)) packet.append(src_ipp) return packet
475,104
def __init__(self, body = None): SipGenericHF.__init__(self, body) self.parsed = True if body == None: self.body = md5(str((random() * 1000000000L) + time())).hexdigest() + '@' + SipConf.my_address
def __init__(self, body = None): SipGenericHF.__init__(self, body) self.parsed = True if body == None: self.body = md5(str((random() * 1000000000L) + time())).hexdigest() + '@' + SipConf.my_address
475,105
def genCallId(self): self.body = md5(str((random() * 1000000000L) + time())).hexdigest() + '@' + SipConf.my_address
def genCallId(self): self.body = md5(str((random() * 1000000000L) + time())).hexdigest() + '@' + SipConf.my_address
475,106
def recvResponse(self, resp): body = resp.getBody() code, reason = resp.getSCode() scode = (code, reason, body) if self.ua.no_reply_timer != None: self.ua.no_reply_timer.cancel() self.ua.no_reply_timer = None if code == 100 and self.ua.no_progress_time != None: self.ua.no_progress_timer = TimeoutAbs(self.ua.no_progress_expires, self.ua.no_progress_time) elif code > 100 and code < 200 and self.ua.expire_time != None: self.ua.expire_timer = TimeoutAbs(self.ua.expires, self.ua.expire_time) if code == 100: if self.ua.p100_ts == None: self.ua.p100_ts = resp.rtime self.ua.equeue.append(CCEventRing(scode, rtime = resp.rtime, origin = self.ua.origin)) return None if self.ua.no_progress_timer != None: self.ua.no_progress_timer.cancel() self.ua.no_progress_timer = None if code < 200 and self.ua.expire_time != None: self.ua.expire_timer = TimeoutAbs(self.ua.expires, self.ua.expire_time) if code < 200: self.ua.last_scode = code event = CCEventRing(scode, rtime = resp.rtime, origin = self.ua.origin) if body != None: if self.ua.on_remote_sdp_change != None: self.ua.on_remote_sdp_change(body, lambda x: self.ua.delayed_remote_sdp_update(event, x)) self.ua.p1xx_ts = resp.rtime return (UacStateRinging, self.ua.ring_cbs, resp.rtime, self.ua.origin, code) else: self.ua.rSDP = body.getCopy() else: self.ua.rSDP = None self.ua.equeue.append(event) self.ua.p1xx_ts = resp.rtime return (UacStateRinging, self.ua.ring_cbs, resp.rtime, self.ua.origin, code) if self.ua.expire_timer != None: self.ua.expire_timer.cancel() self.ua.expire_timer = None if code >= 200 and code < 300: if resp.countHFs('contact') > 0: self.ua.rTarget = resp.getHFBody('contact').getUrl().getCopy() self.ua.routes = [x.getCopy() for x in resp.getHFBodys('record-route')] self.ua.routes.reverse() if len(self.ua.routes) > 0: if not self.ua.routes[0].getUrl().lr: self.ua.routes.append(SipRoute(address = SipAddress(url = self.ua.rTarget.getCopy()))) self.ua.rTarget = self.ua.routes.pop(0).getUrl() self.ua.rAddr = self.ua.rTarget.getAddr() else: self.ua.rAddr = self.ua.routes[0].getAddr() else: self.ua.rAddr = self.ua.rTarget.getAddr() self.ua.rUri.setTag(resp.getHFBody('to').getTag()) event = CCEventConnect(scode, rtime = resp.rtime, origin = self.ua.origin) self.ua.startCreditTimer(resp.rtime) if body != None: if self.ua.on_remote_sdp_change != None: self.ua.on_remote_sdp_change(body, lambda x: self.ua.delayed_remote_sdp_update(event, x)) self.ua.connect_ts = resp.rtime return (UaStateConnected, self.ua.conn_cbs, resp.rtime, self.ua.origin) else: self.ua.rSDP = body.getCopy() else: self.ua.rSDP = None self.ua.equeue.append(event) self.ua.connect_ts = resp.rtime return (UaStateConnected, self.ua.conn_cbs, resp.rtime, self.ua.origin) if code in (301, 302) and resp.countHFs('contact') > 0: scode = (code, reason, body, resp.getHFBody('contact').getUrl().getCopy()) self.ua.equeue.append(CCEventRedirect(scode, rtime = resp.rtime, origin = self.ua.origin)) else: event = CCEventFail(scode, rtime = resp.rtime, origin = self.ua.origin) try: event.reason = resp.getHFBody('reason') except: pass self.ua.equeue.append(event) self.ua.disconnect_ts = resp.rtime return (UaStateFailed, self.ua.fail_cbs, resp.rtime, self.ua.origin, code)
def recvResponse(self, resp): body = resp.getBody() code, reason = resp.getSCode() scode = (code, reason, body) if self.ua.no_reply_timer != None: self.ua.no_reply_timer.cancel() self.ua.no_reply_timer = None if code == 100 and self.ua.no_progress_time != None: self.ua.no_progress_timer = TimeoutAbs(self.ua.no_progress_expires, self.ua.no_progress_time) elif code < 200 and self.ua.expire_time != None: self.ua.expire_timer = TimeoutAbs(self.ua.expires, self.ua.expire_time) if code == 100: if self.ua.p100_ts == None: self.ua.p100_ts = resp.rtime self.ua.equeue.append(CCEventRing(scode, rtime = resp.rtime, origin = self.ua.origin)) return None if self.ua.no_progress_timer != None: self.ua.no_progress_timer.cancel() self.ua.no_progress_timer = None if code < 200 and self.ua.expire_time != None: self.ua.expire_timer = TimeoutAbs(self.ua.expires, self.ua.expire_time) if code < 200: self.ua.last_scode = code event = CCEventRing(scode, rtime = resp.rtime, origin = self.ua.origin) if body != None: if self.ua.on_remote_sdp_change != None: self.ua.on_remote_sdp_change(body, lambda x: self.ua.delayed_remote_sdp_update(event, x)) self.ua.p1xx_ts = resp.rtime return (UacStateRinging, self.ua.ring_cbs, resp.rtime, self.ua.origin, code) else: self.ua.rSDP = body.getCopy() else: self.ua.rSDP = None self.ua.equeue.append(event) self.ua.p1xx_ts = resp.rtime return (UacStateRinging, self.ua.ring_cbs, resp.rtime, self.ua.origin, code) if self.ua.expire_timer != None: self.ua.expire_timer.cancel() self.ua.expire_timer = None if code >= 200 and code < 300: if resp.countHFs('contact') > 0: self.ua.rTarget = resp.getHFBody('contact').getUrl().getCopy() self.ua.routes = [x.getCopy() for x in resp.getHFBodys('record-route')] self.ua.routes.reverse() if len(self.ua.routes) > 0: if not self.ua.routes[0].getUrl().lr: self.ua.routes.append(SipRoute(address = SipAddress(url = self.ua.rTarget.getCopy()))) self.ua.rTarget = self.ua.routes.pop(0).getUrl() self.ua.rAddr = self.ua.rTarget.getAddr() else: self.ua.rAddr = self.ua.routes[0].getAddr() else: self.ua.rAddr = self.ua.rTarget.getAddr() self.ua.rUri.setTag(resp.getHFBody('to').getTag()) event = CCEventConnect(scode, rtime = resp.rtime, origin = self.ua.origin) self.ua.startCreditTimer(resp.rtime) if body != None: if self.ua.on_remote_sdp_change != None: self.ua.on_remote_sdp_change(body, lambda x: self.ua.delayed_remote_sdp_update(event, x)) self.ua.connect_ts = resp.rtime return (UaStateConnected, self.ua.conn_cbs, resp.rtime, self.ua.origin) else: self.ua.rSDP = body.getCopy() else: self.ua.rSDP = None self.ua.equeue.append(event) self.ua.connect_ts = resp.rtime return (UaStateConnected, self.ua.conn_cbs, resp.rtime, self.ua.origin) if code in (301, 302) and resp.countHFs('contact') > 0: scode = (code, reason, body, resp.getHFBody('contact').getUrl().getCopy()) self.ua.equeue.append(CCEventRedirect(scode, rtime = resp.rtime, origin = self.ua.origin)) else: event = CCEventFail(scode, rtime = resp.rtime, origin = self.ua.origin) try: event.reason = resp.getHFBody('reason') except: pass self.ua.equeue.append(event) self.ua.disconnect_ts = resp.rtime return (UaStateFailed, self.ua.fail_cbs, resp.rtime, self.ua.origin, code)
475,107
def recvResponse(self, resp): body = resp.getBody() code, reason = resp.getSCode() scode = (code, reason, body) if code < 200: self.ua.equeue.append(CCEventRing(scode, rtime = resp.rtime, origin = self.ua.origin)) return None if code >= 200 and code < 300: event = CCEventConnect(scode, rtime = resp.rtime, origin = self.ua.origin) if body != None: if self.ua.on_remote_sdp_change != None: self.ua.on_remote_sdp_change(body, lambda x: self.ua.delayed_remote_sdp_update(event, x)) return (UaStateConnected,) else: self.ua.rSDP = body.getCopy() else: self.ua.rSDP = None self.ua.equeue.append(event) return (UaStateConnected,) if code in (301, 302) and resp.countHFs('contact') > 0: scode = (code, reason, body, resp.getHFBody('contact').getUrl().getCopy()) self.ua.equeqe.append(CCEventRedirect(scode, rtime = resp.rtime, origin = self.ua.origin)) elif code in (408, 481): # If the response for a request within a dialog is a 481 # (Call/Transaction Does Not Exist) or a 408 (Request Timeout), the UAC # SHOULD terminate the dialog. A UAC SHOULD also terminate a dialog if # no response at all is received for the request (the client # transaction would inform the TU about the timeout.) event = CCEventDisconnect(rtime = resp.rtime, origin = self.ua.origin) try: event.reason = resp.getHFBody('reason') except: pass self.ua.equeue.append(event) self.ua.cancelCreditTimer() self.ua.disconnect_ts = resp.rtime return (UaStateDisconnected, self.ua.disc_cbs, resp.rtime, self.ua.origin) else: event = CCEventFail(scode, rtime = resp.rtime, origin = self.ua.origin) try: event.reason = resp.getHFBody('reason') except: pass self.ua.equeue.append(event) return (UaStateConnected,)
def recvResponse(self, resp): body = resp.getBody() code, reason = resp.getSCode() scode = (code, reason, body) if code < 200: self.ua.equeue.append(CCEventRing(scode, rtime = resp.rtime, origin = self.ua.origin)) return None if code >= 200 and code < 300: event = CCEventConnect(scode, rtime = resp.rtime, origin = self.ua.origin) if body != None: if self.ua.on_remote_sdp_change != None: self.ua.on_remote_sdp_change(body, lambda x: self.ua.delayed_remote_sdp_update(event, x)) return (UaStateConnected,) else: self.ua.rSDP = body.getCopy() else: self.ua.rSDP = None self.ua.equeue.append(event) return (UaStateConnected,) if code in (301, 302) and resp.countHFs('contact') > 0: scode = (code, reason, body, resp.getHFBody('contact').getUrl().getCopy()) self.ua.equeue.append(CCEventRedirect(scode, rtime = resp.rtime, origin = self.ua.origin)) elif code in (408, 481): # If the response for a request within a dialog is a 481 # (Call/Transaction Does Not Exist) or a 408 (Request Timeout), the UAC # SHOULD terminate the dialog. A UAC SHOULD also terminate a dialog if # no response at all is received for the request (the client # transaction would inform the TU about the timeout.) event = CCEventDisconnect(rtime = resp.rtime, origin = self.ua.origin) try: event.reason = resp.getHFBody('reason') except: pass self.ua.equeue.append(event) self.ua.cancelCreditTimer() self.ua.disconnect_ts = resp.rtime return (UaStateDisconnected, self.ua.disc_cbs, resp.rtime, self.ua.origin) else: event = CCEventFail(scode, rtime = resp.rtime, origin = self.ua.origin) try: event.reason = resp.getHFBody('reason') except: pass self.ua.equeue.append(event) return (UaStateConnected,)
475,108
def mmrrc(): mmrrcfp = reportlib.init(sys.argv[0], outputdir = os.environ['QCOUTPUTDIR'], fileExt = '.mmrrc.rpt') title = 'MMRRC Strains w/ Genotype Associations where the Markers/Alleles of the Strain record\n' + \ 'do not exactly match the Markers/Alleles of the Genotype record.' mmncfp.write(title + '\n\n') mmncfp.write('MMRRC#' + reportlib.TAB) mmncfp.write('Strain' + reportlib.TAB) mmncfp.write('Genotypes' + reportlib.TAB) mmncfp.write(reportlib.CRT) # MMNC Strains w/ Genotype Associations; exclude wild type alleles db.sql('''select distinct sa.accID, s.strain, g._Genotype_key, g._Strain_key, a._Marker_key, a._Allele_key into #strains from PRB_Strain s, PRB_Strain_Genotype g, GXD_AlleleGenotype a, ALL_Allele aa, ACC_Accession sa where s.strain like "%/Mmnc" and s._Strain_key = g._Strain_key and g._Genotype_key = a._Genotype_key and a._Allele_key = aa._Allele_key and aa.isWildType = 0 and s._Strain_key = sa._Object_key and sa._MGIType_key = 10 and sa._LogicalDB_key = 38 and sa.preferred = 1 ''', None) db.sql('create index idx1 on #strains(_Strain_key)', None) printReport(mmrrcfp)
def mmrrc(): mmrrcfp = reportlib.init(sys.argv[0], outputdir = os.environ['QCOUTPUTDIR'], fileExt = '.mmrrc.rpt') title = 'MMRRC Strains w/ Genotype Associations where the Markers/Alleles of the Strain record\n' + \ 'do not exactly match the Markers/Alleles of the Genotype record.' mmncfp.write(title + '\n\n') mmncfp.write('MMRRC#' + reportlib.TAB) mmncfp.write('Strain' + reportlib.TAB) mmncfp.write('Genotypes' + reportlib.TAB) mmncfp.write(reportlib.CRT) # MMNC Strains w/ Genotype Associations; exclude wild type alleles db.sql('''select distinct sa.accID, s.strain, g._Genotype_key, g._Strain_key, a._Marker_key, a._Allele_key into #strains from PRB_Strain s, PRB_Strain_Genotype g, GXD_AlleleGenotype a, ALL_Allele aa, ACC_Accession sa where s.strain like "%/Mmnc" and s._Strain_key = g._Strain_key and g._Genotype_key = a._Genotype_key and a._Allele_key = aa._Allele_key and aa.isWildType = 0 and s._Strain_key = sa._Object_key and sa._MGIType_key = 10 and sa._LogicalDB_key = 38 and sa.preferred = 1 ''', None) db.sql('create index idx1 on #strains(_Strain_key)', None) printReport(mmrrcfp)
475,109
def to_point(self): '''Convert from PolarPoint to (cartesian) Point object'''
def to_point(self): '''Convert from PolarPoint to (cartesian) Point object'''
475,110
def connect_action(self, event):
def connect_action(self, event):
475,111
def connect_action(self, event):
def connect_action(self, event):
475,112
def connect_action(self, event):
def connect_action(self, event):
475,113
def connect_action(self, event):
def connect_action(self, event):
475,114
def is_point(self, line):
def is_point(self, line):
475,115
def _points(self): points = [] for row in rows: fs = row.split(',') if fs[0] == 'ST': x = fs[-3] # FIXME NEZ coord order shouldn't be hardcoded y = fs[-2] z = fs[-1] bp = BasePoint(x=x, y=y, z=z, ih=0) if fs[0] == 'SS': angle = fs[4] z_angle = fs[5] dist = fs[3] th = fs[2] p = PolarPoint(dist=dist, angle=angle, z_angle=z_angle, th=th, angle_type='gon', base_point=bp) points.append(p.to_point()) return points
def _points(self): points = [] for row in rows: fs = row.split(',') if fs[0] == 'ST': x = fs[-3] # FIXME NEZ coord order shouldn't be hardcoded y = fs[-2] z = fs[-1] bp = BasePoint(x=x, y=y, z=z, ih=0) if fs[0] == 'SS': angle = fs[4] z_angle = fs[5] dist = fs[3] th = fs[2] p = PolarPoint(dist=dist, angle=angle, z_angle=z_angle, th=th, angle_type='gon', base_point=bp) points.append(p.to_point()) return points
475,116
def url(dialog, link, data=None): pass
def url(dialog, link, data=None): pass
475,117
def _check_for_Flash(self): try: tmp = "/tmp" ## look for filenames that begin with 'Flash' for file in os.listdir(tmp): try: if file.startswith("Flash"): filepath = os.path.join(tmp, file) duration = utils.getFLVLength(filepath)
def _check_for_Flash(self): try: tmp = "/tmp" ## look for filenames that begin with 'Flash' for file in os.listdir(tmp): try: if file.startswith("Flash"): filepath = os.path.join(tmp, file) duration = utils.getFLVLength(filepath)
475,118
def _check_for_Flash(self): try: tmp = "/tmp" ## look for filenames that begin with 'Flash' for file in os.listdir(tmp): try: if file.startswith("Flash"): filepath = os.path.join(tmp, file) duration = utils.getFLVLength(filepath)
def _check_for_Flash(self): try: tmp = "/tmp" ## look for filenames that begin with 'Flash' for file in os.listdir(tmp): try: if file.startswith("Flash"): filepath = os.path.join(tmp, file) duration = utils.getFLVLength(filepath)
475,119
def __init__(self): self.Core = core.Caffeine()
def __init__(self): self.Core = core.Caffeine()
475,120
def on_about_button_clicked (self, button, data=None):
def on_about_button_clicked (self, button, data=None):
475,121
def on_time_submenuitem_activate(self, menuitem, time):
def on_time_submenuitem_activate(self, menuitem, time):
475,122
def _run_dialog(self): response = self.about_dialog.run() self.about_dialog.destroy() return False
def on_about_menuitem_activate(self, menuitem, data=None): if appindicator_avail: gtk.gdk.threads_enter() self.about_dialog.set_position (gtk.WIN_POS_CENTER_ALWAYS) response = self.about_dialog.run() self.about_dialog.destroy() return False
475,123
def _run_dialog(self): response = self.about_dialog.run() self.about_dialog.destroy() return False
def _run_dialog(self): response = self.about_dialog.run() self.about_dialog.destroy() return False
475,124
def quit(self): ### Do anything that needs to be done before quitting. logging.info("Caffeine is preparing to quit")
def quit(self): ### Do anything that needs to be done before quitting. logging.info("Caffeine is preparing to quit")
475,125
def os_chown(self, path, uid, gid): ino = self.ino_from_path(path) inode = self.inode_read(ino) inode["uid"] = uid inode["gid"] = gid self.inode_write(ino, inode)
def os_chown(self, path, uid, gid): ino = self.ino_from_path(path) if uid == -1 and gid == -1: return inode = self.inode_read(ino) if uid != -1: inode["uid"] = uid if gid != -1: inode["gid"] = gid if inode["mode"] & (S_IXUSR|S_IXGRP|S_IXOTH): inode["mode"] &= ~(S_ISUID|S_ISGID) inode.set_time_fields(change=True) self.inode_write(ino, inode)
475,126
def _rmdir(self, dirino, name): offset, dirent = self._scandir(dirino, name) inode = self.inode_read(dirent["ino"]) if not S_ISDIR(inode["mode"]): raise ClfsError(ENOTDIR) if inode["nlink"] > 2: raise ClfsError(ENOTEMPTY) if inode["nlink"] < 2: logger.error( "Directory inode %i has invalid link count %i", dirent["ino"], inode["nlink"]) # free all the clusters of the directory self.chain_shorten(dirent["ino"], 0) # this is now invalidated and useless del inode dirinode = self.inode_read(dirino) # we're removing a subdir dirinode["nlink"] -= 1 self.dir_remove(dirino, offset, dirinode) self.inode_write(dirino, dirinode)
def _rmdir(self, pino, name): offset, dirent = self._scandir(pino, name) ino = dirent["ino"] inode = self.inode_read(ino) if not S_ISDIR(inode["mode"]): raise ClfsError(ENOTDIR) if inode["nlink"] > 2: raise ClfsError(ENOTEMPTY) if inode["nlink"] < 2: logger.error( "Directory inode %i has invalid link count %i", dirent["ino"], inode["nlink"]) # free all the clusters of the directory self.chain_shorten(dirent["ino"], 0) # this is now invalidated and useless del inode dirinode = self.inode_read(dirino) # we're removing a subdir dirinode["nlink"] -= 1 self.dir_remove(dirino, offset, dirinode) self.inode_write(dirino, dirinode)
475,127
def _rmdir(self, dirino, name): offset, dirent = self._scandir(dirino, name) inode = self.inode_read(dirent["ino"]) if not S_ISDIR(inode["mode"]): raise ClfsError(ENOTDIR) if inode["nlink"] > 2: raise ClfsError(ENOTEMPTY) if inode["nlink"] < 2: logger.error( "Directory inode %i has invalid link count %i", dirent["ino"], inode["nlink"]) # free all the clusters of the directory self.chain_shorten(dirent["ino"], 0) # this is now invalidated and useless del inode dirinode = self.inode_read(dirino) # we're removing a subdir dirinode["nlink"] -= 1 self.dir_remove(dirino, offset, dirinode) self.inode_write(dirino, dirinode)
def _rmdir(self, dirino, name): offset, dirent = self._scandir(dirino, name) inode = self.inode_read(dirent["ino"]) if not S_ISDIR(inode["mode"]): raise ClfsError(ENOTDIR) if inode["nlink"] < 2: logger.error( "Directory inode %i has invalid link count %i", dirent["ino"], inode["nlink"]) # free all the clusters of the directory self.chain_shorten(dirent["ino"], 0) # this is now invalidated and useless del inode dirinode = self.inode_read(dirino) # we're removing a subdir dirinode["nlink"] -= 1 self.dir_remove(dirino, offset, dirinode) self.inode_write(dirino, dirinode)
475,128
def _rmdir(self, dirino, name): offset, dirent = self._scandir(dirino, name) inode = self.inode_read(dirent["ino"]) if not S_ISDIR(inode["mode"]): raise ClfsError(ENOTDIR) if inode["nlink"] > 2: raise ClfsError(ENOTEMPTY) if inode["nlink"] < 2: logger.error( "Directory inode %i has invalid link count %i", dirent["ino"], inode["nlink"]) # free all the clusters of the directory self.chain_shorten(dirent["ino"], 0) # this is now invalidated and useless del inode dirinode = self.inode_read(dirino) # we're removing a subdir dirinode["nlink"] -= 1 self.dir_remove(dirino, offset, dirinode) self.inode_write(dirino, dirinode)
def _rmdir(self, dirino, name): offset, dirent = self._scandir(dirino, name) inode = self.inode_read(dirent["ino"]) if not S_ISDIR(inode["mode"]): raise ClfsError(ENOTDIR) if inode["nlink"] > 2: raise ClfsError(ENOTEMPTY) if inode["nlink"] < 2: logger.error( "Directory inode %i has invalid link count %i", ino, inode["nlink"]) if inode["nlink"] > 2: raise ClfsError(ENOTEMPTY) else: try: self.dir_iter(ino, inode).next() except StopIteration: pass else: raise ClfsError(ENOTEMPTY) # free all the clusters of the directory self.chain_shorten(dirent["ino"], 0) # this is now invalidated and useless del inode dirinode = self.inode_read(dirino) # we're removing a subdir dirinode["nlink"] -= 1 self.dir_remove(dirino, offset, dirinode) self.inode_write(dirino, dirinode)
475,129
def _rmdir(self, dirino, name): offset, dirent = self._scandir(dirino, name) inode = self.inode_read(dirent["ino"]) if not S_ISDIR(inode["mode"]): raise ClfsError(ENOTDIR) if inode["nlink"] > 2: raise ClfsError(ENOTEMPTY) if inode["nlink"] < 2: logger.error( "Directory inode %i has invalid link count %i", dirent["ino"], inode["nlink"]) # free all the clusters of the directory self.chain_shorten(dirent["ino"], 0) # this is now invalidated and useless del inode dirinode = self.inode_read(dirino) # we're removing a subdir dirinode["nlink"] -= 1 self.dir_remove(dirino, offset, dirinode) self.inode_write(dirino, dirinode)
def _rmdir(self, dirino, name): offset, dirent = self._scandir(dirino, name) inode = self.inode_read(dirent["ino"]) if not S_ISDIR(inode["mode"]): raise ClfsError(ENOTDIR) if inode["nlink"] > 2: raise ClfsError(ENOTEMPTY) if inode["nlink"] < 2: logger.error( "Directory inode %i has invalid link count %i", dirent["ino"], inode["nlink"]) # free all the clusters of the directory self.chain_shorten(ino, 0) # this is now invalidated and useless del inode dirinode = self.inode_read(dirino) # we're removing a subdir dirinode["nlink"] -= 1 self.dir_remove(dirino, offset, dirinode) self.inode_write(dirino, dirinode)
475,130
def _rmdir(self, dirino, name): offset, dirent = self._scandir(dirino, name) inode = self.inode_read(dirent["ino"]) if not S_ISDIR(inode["mode"]): raise ClfsError(ENOTDIR) if inode["nlink"] > 2: raise ClfsError(ENOTEMPTY) if inode["nlink"] < 2: logger.error( "Directory inode %i has invalid link count %i", dirent["ino"], inode["nlink"]) # free all the clusters of the directory self.chain_shorten(dirent["ino"], 0) # this is now invalidated and useless del inode dirinode = self.inode_read(dirino) # we're removing a subdir dirinode["nlink"] -= 1 self.dir_remove(dirino, offset, dirinode) self.inode_write(dirino, dirinode)
def _rmdir(self, dirino, name): offset, dirent = self._scandir(dirino, name) inode = self.inode_read(dirent["ino"]) if not S_ISDIR(inode["mode"]): raise ClfsError(ENOTDIR) if inode["nlink"] > 2: raise ClfsError(ENOTEMPTY) if inode["nlink"] < 2: logger.error( "Directory inode %i has invalid link count %i", dirent["ino"], inode["nlink"]) # free all the clusters of the directory self.chain_shorten(dirent["ino"], 0) # this is now invalidated and useless del inode self.inode_write(ino, Inode()) pinode = self.inode_read(pino) # we're removing a subdir dirinode["nlink"] -= 1 self.dir_remove(dirino, offset, dirinode) self.inode_write(dirino, dirinode)
475,131
def _rmdir(self, dirino, name): offset, dirent = self._scandir(dirino, name) inode = self.inode_read(dirent["ino"]) if not S_ISDIR(inode["mode"]): raise ClfsError(ENOTDIR) if inode["nlink"] > 2: raise ClfsError(ENOTEMPTY) if inode["nlink"] < 2: logger.error( "Directory inode %i has invalid link count %i", dirent["ino"], inode["nlink"]) # free all the clusters of the directory self.chain_shorten(dirent["ino"], 0) # this is now invalidated and useless del inode dirinode = self.inode_read(dirino) # we're removing a subdir dirinode["nlink"] -= 1 self.dir_remove(dirino, offset, dirinode) self.inode_write(dirino, dirinode)
def _rmdir(self, dirino, name): offset, dirent = self._scandir(dirino, name) inode = self.inode_read(dirent["ino"]) if not S_ISDIR(inode["mode"]): raise ClfsError(ENOTDIR) if inode["nlink"] > 2: raise ClfsError(ENOTEMPTY) if inode["nlink"] < 2: logger.error( "Directory inode %i has invalid link count %i", dirent["ino"], inode["nlink"]) # free all the clusters of the directory self.chain_shorten(dirent["ino"], 0) # this is now invalidated and useless del inode dirinode = self.inode_read(dirino) # we're removing a subdir dirinode["nlink"] -= 1 self.dir_remove(dirino, offset, dirinode) self.inode_write(dirino, dirinode)
475,132
def __repr__(self): return "<{0} {1}>".format(self.__class__.__name__, self.__values)
def __repr__(self): return "<{0} {1}>".format(self.__class__.__name__, self.__values)
475,133
def __init__(self, errno): self.errno = errno
def __init__(self, errno): self.errno = errno
475,134
def create_node(self, path, type): #pdb.set_trace() node_dirname, node_basename = os.path.split(path) parent_dirname, parent_basename = os.path.split(node_dirname) parent_dirent = self.get_dir_entry(node_dirname) parent_inode_struct = self.get_inode_struct(parent_dirent["inode"]) for dirent in self.read_directory(parent_dirent["inode"]): if dirent["name"].rstrip("\0") == node_basename: raise ClfsError(EEXIST) new_dirent = DirEntry(name=node_basename, inode=self.claim_free_cluster()) # write the new dirent at the end of the parent directory assert new_dirent.size == self.write_inode_data( parent_dirent["inode"], parent_inode_struct["size"], new_dirent.pack(),) # initialize the new inode #pdb.set_trace() new_inode = Inode(type=type, size=0, links=1) assert (new_inode.size, new_inode.size) == self.write_to_chain( new_dirent["inode"], 0, 0, new_inode.pack())
defcreate_node(self,path,type):#pdb.set_trace()node_dirname,node_basename=os.path.split(path)parent_dirname,parent_basename=os.path.split(node_dirname)parent_dirent=self.get_dir_entry(node_dirname)parent_inode_struct=self.get_inode_struct(parent_dirent["inode"])fordirentinself.read_directory(parent_dirent["inode"]):ifdirent["name"].rstrip("\0")==node_basename:raiseClfsError(EEXIST)new_dirent=DirEntry(name=node_basename,inode=self.claim_free_cluster())#writethenewdirentattheendoftheparentdirectoryassertnew_dirent.size==self.write_inode_data(parent_dirent["inode"],parent_inode_struct["size"],new_dirent.pack(),)#initializethenewinode#pdb.set_trace()new_inode=Inode(type=type,size=0,links=1)assert(new_inode.size,new_inode.size)==self.write_to_chain(new_dirent["inode"],0,0,new_inode.pack())
475,135
def create_node(self, path, type): #pdb.set_trace() node_dirname, node_basename = os.path.split(path) parent_dirname, parent_basename = os.path.split(node_dirname) parent_dirent = self.get_dir_entry(node_dirname) parent_inode_struct = self.get_inode_struct(parent_dirent["inode"]) for dirent in self.read_directory(parent_dirent["inode"]): if dirent["name"].rstrip("\0") == node_basename: raise ClfsError(EEXIST) new_dirent = DirEntry(name=node_basename, inode=self.claim_free_cluster()) # write the new dirent at the end of the parent directory assert new_dirent.size == self.write_inode_data( parent_dirent["inode"], parent_inode_struct["size"], new_dirent.pack(),) # initialize the new inode #pdb.set_trace() new_inode = Inode(type=type, size=0, links=1) assert (new_inode.size, new_inode.size) == self.write_to_chain( new_dirent["inode"], 0, 0, new_inode.pack())
def create_node(self, path, type): #pdb.set_trace() node_dirname, node_basename = os.path.split(path) parent_dirname, parent_basename = os.path.split(node_dirname) parent_dirent = self.get_dir_entry(node_dirname) parent_inode_struct = self.get_inode_struct(parent_dirent["inode"]) for dirent in self.read_directory(parent_dirent["inode"]): if dirent["name"].rstrip("\0") == node_basename: raise ClfsError(EEXIST) new_dirent = DirEntry(name=node_basename, inode=self.claim_free_cluster()) # write the new dirent at the end of the parent directory assert new_dirent.size == self.write_inode_data( parent_dirent["inode"], parent_inode_struct["size"], new_dirent.pack(),) # initialize the new inode #pdb.set_trace() new_inode = Inode(type=type, size=0) if type == TYPE_DIRECTORY: new_inode["links"] = 2 elif type == TYPE_REGULAR_FILE: new_inode["links"] = 1 assert (new_inode.size, new_inode.size) == self.write_to_chain( new_dirent["inode"], 0, 0, new_inode.pack())
475,136
def pz_locked(doc, pageContext): world = pageContext.get_selected_world() curtime = int(time.time()) limits = (0, 30) #limits = (0, 200) doc.write("Players sorted by descending protection zone lock time remaining. Also shown is their level, vocation, guild, and most recent victim.") with stattab_table_tag(doc.open_tag): with doc.open_tag("tr", inline=False): if not world: doc.add_tag("th", "World") doc.add_tag("th", "PZ Lock End") doc.add_tag("th", "Killer") doc.add_tag("th", "Level") doc.add_tag("th", "Vocation") doc.add_tag("th", "Guild") doc.add_tag("th", "Last Victim") rowColor = stattab_row_class() for pzlock in dbiface.get_last_pzlocks(world, limits): killerInfo = dbiface.get_char(pzlock["killer"]) #pdb.set_trace() pzEndStamp = dbiface.pz_end(pzlock) if world is None or killerInfo["world"] == world: rowAttrs = {"class": rowColor.next()} if pzEndStamp < int(time.time()): rowAttrs["class"] += " greyed" with doc.open_tag("tr", attrs=rowAttrs, inline=False): assert killerInfo["name"] == pzlock["killer"] if not world: doc.add_tag("td", killerInfo["world"]) doc.add_tag("td", human_time_diff(pzEndStamp)) doc.add_tag("td", char_link(pzlock["killer"])) for field in ("level", "vocation"): doc.add_tag("td", killerInfo[field]) doc.add_tag("td", pageContext.guild_link(killerInfo["guild"])) doc.add_tag("td", char_link(pzlock["victim"]))
def pz_locked(doc, pageContext): world = pageContext.get_selected_world() curtime = int(time.time()) limits = (0, 30) #limits = (0, 200) doc.add_tag("p", data="Players sorted by descending protection zone lock time remaining. Also shown is their level, vocation, guild, and most recent victim. Shown first are those that are still PZL'd. The second table contains those that should have lost their PZL by now.") column_count = 6 if not world: column_count += 1 with stattab_table_tag(doc.open_tag): with doc.open_tag("tr", inline=False): if not world: doc.add_tag("th", "World") doc.add_tag("th", "PZ Lock End") doc.add_tag("th", "Killer") doc.add_tag("th", "Level") doc.add_tag("th", "Vocation") doc.add_tag("th", "Guild") doc.add_tag("th", "Last Victim") rowColor = stattab_row_class() for pzlock in dbiface.get_last_pzlocks(world, limits): killerInfo = dbiface.get_char(pzlock["killer"]) #pdb.set_trace() pzEndStamp = dbiface.pz_end(pzlock) if world is None or killerInfo["world"] == world: rowAttrs = {"class": rowColor.next()} if pzEndStamp < int(time.time()): rowAttrs["class"] += " greyed" with doc.open_tag("tr", attrs=rowAttrs, inline=False): assert killerInfo["name"] == pzlock["killer"] if not world: doc.add_tag("td", killerInfo["world"]) doc.add_tag("td", human_time_diff(pzEndStamp)) doc.add_tag("td", char_link(pzlock["killer"])) for field in ("level", "vocation"): doc.add_tag("td", killerInfo[field]) doc.add_tag("td", pageContext.guild_link(killerInfo["guild"])) doc.add_tag("td", char_link(pzlock["victim"]))
475,137
def pz_locked(doc, pageContext): world = pageContext.get_selected_world() curtime = int(time.time()) limits = (0, 30) #limits = (0, 200) doc.write("Players sorted by descending protection zone lock time remaining. Also shown is their level, vocation, guild, and most recent victim.") with stattab_table_tag(doc.open_tag): with doc.open_tag("tr", inline=False): if not world: doc.add_tag("th", "World") doc.add_tag("th", "PZ Lock End") doc.add_tag("th", "Killer") doc.add_tag("th", "Level") doc.add_tag("th", "Vocation") doc.add_tag("th", "Guild") doc.add_tag("th", "Last Victim") rowColor = stattab_row_class() for pzlock in dbiface.get_last_pzlocks(world, limits): killerInfo = dbiface.get_char(pzlock["killer"]) #pdb.set_trace() pzEndStamp = dbiface.pz_end(pzlock) if world is None or killerInfo["world"] == world: rowAttrs = {"class": rowColor.next()} if pzEndStamp < int(time.time()): rowAttrs["class"] += " greyed" with doc.open_tag("tr", attrs=rowAttrs, inline=False): assert killerInfo["name"] == pzlock["killer"] if not world: doc.add_tag("td", killerInfo["world"]) doc.add_tag("td", human_time_diff(pzEndStamp)) doc.add_tag("td", char_link(pzlock["killer"])) for field in ("level", "vocation"): doc.add_tag("td", killerInfo[field]) doc.add_tag("td", pageContext.guild_link(killerInfo["guild"])) doc.add_tag("td", char_link(pzlock["victim"]))
def pz_locked(doc, pageContext): world = pageContext.get_selected_world() curtime = int(time.time()) limits = (0, 30) #limits = (0, 200) doc.write("Players sorted by descending protection zone lock time remaining. Also shown is their level, vocation, guild, and most recent victim.") with stattab_table_tag(doc.open_tag): def add_header_row(): with doc.open_tag("tr", inline=False): if not world: doc.add_tag("th", "World") doc.add_tag("th", "PZ Lock End") doc.add_tag("th", "Killer") doc.add_tag("th", "Level") doc.add_tag("th", "Vocation") doc.add_tag("th", "Guild") doc.add_tag("th", "Last Victim") add_header_row() rowColor = stattab_row_class() for pzlock in dbiface.get_last_pzlocks(world, limits): killerInfo = dbiface.get_char(pzlock["killer"]) #pdb.set_trace() pzEndStamp = dbiface.pz_end(pzlock) if world is None or killerInfo["world"] == world: rowAttrs = {"class": rowColor.next()} if pzEndStamp < int(time.time()): rowAttrs["class"] += " greyed" with doc.open_tag("tr", attrs=rowAttrs, inline=False): assert killerInfo["name"] == pzlock["killer"] if not world: doc.add_tag("td", killerInfo["world"]) doc.add_tag("td", human_time_diff(pzEndStamp)) doc.add_tag("td", char_link(pzlock["killer"])) for field in ("level", "vocation"): doc.add_tag("td", killerInfo[field]) doc.add_tag("td", pageContext.guild_link(killerInfo["guild"])) doc.add_tag("td", char_link(pzlock["victim"]))
475,138
def pz_locked(doc, pageContext): world = pageContext.get_selected_world() curtime = int(time.time()) limits = (0, 30) #limits = (0, 200) doc.write("Players sorted by descending protection zone lock time remaining. Also shown is their level, vocation, guild, and most recent victim.") with stattab_table_tag(doc.open_tag): with doc.open_tag("tr", inline=False): if not world: doc.add_tag("th", "World") doc.add_tag("th", "PZ Lock End") doc.add_tag("th", "Killer") doc.add_tag("th", "Level") doc.add_tag("th", "Vocation") doc.add_tag("th", "Guild") doc.add_tag("th", "Last Victim") rowColor = stattab_row_class() for pzlock in dbiface.get_last_pzlocks(world, limits): killerInfo = dbiface.get_char(pzlock["killer"]) #pdb.set_trace() pzEndStamp = dbiface.pz_end(pzlock) if world is None or killerInfo["world"] == world: rowAttrs = {"class": rowColor.next()} if pzEndStamp < int(time.time()): rowAttrs["class"] += " greyed" with doc.open_tag("tr", attrs=rowAttrs, inline=False): assert killerInfo["name"] == pzlock["killer"] if not world: doc.add_tag("td", killerInfo["world"]) doc.add_tag("td", human_time_diff(pzEndStamp)) doc.add_tag("td", char_link(pzlock["killer"])) for field in ("level", "vocation"): doc.add_tag("td", killerInfo[field]) doc.add_tag("td", pageContext.guild_link(killerInfo["guild"])) doc.add_tag("td", char_link(pzlock["victim"]))
def pz_locked(doc, pageContext): world = pageContext.get_selected_world() curtime = int(time.time()) limits = (0, 30) #limits = (0, 200) doc.write("Players sorted by descending protection zone lock time remaining. Also shown is their level, vocation, guild, and most recent victim.") with stattab_table_tag(doc.open_tag): with doc.open_tag("tr", inline=False): if not world: doc.add_tag("th", "World") doc.add_tag("th", "PZ Lock End") doc.add_tag("th", "Killer") doc.add_tag("th", "Level") doc.add_tag("th", "Vocation") doc.add_tag("th", "Guild") doc.add_tag("th", "Last Victim") rowColor = stattab_row_class() for pzlock in dbiface.get_last_pzlocks(world, limits): killerInfo = dbiface.get_char(pzlock["killer"]) #pdb.set_trace() pzEndStamp = dbiface.pz_end(pzlock) if world is None or killerInfo["world"] == world: rowAttrs = {"class": rowColor.next()} if not doing_still_pzlocked_rows: rowAttrs["class"] += " greyed" with doc.open_tag("tr", attrs=rowAttrs, inline=False): assert killerInfo["name"] == pzlock["killer"] if not world: doc.add_tag("td", killerInfo["world"]) doc.add_tag("td", human_time_diff(pzEndStamp)) doc.add_tag("td", char_link(pzlock["killer"])) for field in ("level", "vocation"): doc.add_tag("td", killerInfo[field]) doc.add_tag("td", pageContext.guild_link(killerInfo["guild"])) doc.add_tag("td", char_link(pzlock["victim"]))
475,139
def curses_color(): import curses class TermInfo(): # this. is. ANSIIIII!!! _ANSI_COLORS = """BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE""".split() _STRING_CAPS = """NORMAL=sgr0""".split() def __init__(self, stream=sys.stdout): # isatty might be needed here? curses.setupterm(None, stream.fileno()) for prefix, capname in [("FG_", "setaf"), ("BG_", "setab")]: for index, color in zip(range(len(self._ANSI_COLORS)), self._ANSI_COLORS): setattr(self, prefix + color, curses.tparm(curses.tigetstr(capname), index)) for strcap in self._STRING_CAPS: attr, capname = strcap.split("=") setattr(self, attr, curses.tigetstr(capname)) self.stream = stream #def __del__(self): # self.reset() def reset(self): self.immediate(self.NORMAL) def immediate(self, tistr): self.stream.write(tistr) self.stream.flush() def save_color(self): return None def set_color(self, color): self.immediate(getattr(self, "FG_" + color.upper())) def reset_color(self): #self.immediate(self.__color) self.reset() return TermInfo
def curses_color(): import curses class TermInfo(): # this. is. ANSIIIII!!! _ANSI_COLORS = """BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE""".split() _STRING_CAPS = """NORMAL=sgr0""".split() def __init__(self, stream=sys.stdout): # isatty might be needed here? curses.setupterm(None, stream.fileno()) for prefix, capname in [("FG_", "setaf"), ("BG_", "setab")]: for index, color in zip(range(len(self._ANSI_COLORS)), self._ANSI_COLORS): setattr(self, prefix + color, curses.tparm(curses.tigetstr(capname), index)) for strcap in self._STRING_CAPS: attr, capname = strcap.split("=") setattr(self, attr, curses.tigetstr(capname)) self.stream = stream #def __del__(self): # self.reset() def reset(self): self.immediate(self.NORMAL) def immediate(self, tistr): self.stream.write(tistr) self.stream.flush() def save_color(self): return None def set_color(self, color): self.immediate(getattr(self, "FG_" + color.upper())) def reset_color(self): #self.immediate(self.__color) self.reset() return TermInfo
475,140
def select_color(): try: import curses except ImportError: import ctypes try: from ctypes import wintypes finally: pass return windows_color() else: return curses_color() assert False
def select_color(): for a in [curses_color, windows_color]: b = a() if b != None: return b else: return curses_color() assert False
475,141
def select_color(): try: import curses except ImportError: import ctypes try: from ctypes import wintypes finally: pass return windows_color() else: return curses_color() assert False
def select_color(): try: import curses except ImportError: import ctypes try: from ctypes import wintypes finally: pass return windows_color() else: assert False
475,142
def __get__(self, instance, owner): #assert instance == None, instance return property.__get__(self, owner)
def__get__(self,instance,owner):#assertinstance==None,instancereturnproperty.__get__(self,owner)
475,143
def ClfsStructField(*args): a = list(args) if len(a) < 3: a.append(None) else: assert a[2] != None return collections.namedtuple( "ClfsStructField", ("name", "format", "initval") )(*a)
def ClfsStructField(*args): a = list(args) if len(a) < 3: a.append(None) else: assert a[2] != None, "None is reserved for indicating uninitialized fields" return namedtuple( "ClfsStructField", ("name", "format", "initval") )(*a)
475,144
def all_fields(): for base in bases: if hasattr(base, "fields"): for field in base.fields: yield field for a in attrs["_fields_"]: yield ClfsStructField(*a)
def all_fields(): for base in bases: if hasattr(base, "fields"): for field in base.fields: yield field for a in attrs["_fields_"]: yield ClfsStructField(*a)
475,145
def from_fileobj(class_, fileobj): return class_.unpack(fileobj.read(class_.size))
def from_fileobj(class_, fileobj): return class_.unpack(fileobj.read(class_.size))
475,146
def unpack(class_, buffer): instance = class_() offset = 0 for field in instance.fields: #assert field.name in instance.__values unpacked = struct.unpack_from(field.format, buffer, offset) assert len(unpacked) == 1 instance[field.name] = unpacked[0] #instance.__values[field.name] = unpacked[0] offset += struct.calcsize(field.format) assert offset == len(buffer) return instance
def unpack(class_, buffer): instance = class_() offset = 0 for field in instance.fields: #assert field.name in instance.__values unpacked = struct.unpack_from(field.format, buffer, offset) if len(unpacked): instance[field.name], = unpacked #instance.__values[field.name] = unpacked[0] offset += struct.calcsize(field.format) assert offset == len(buffer) return instance
475,147
def pack(self): buffer = "" for field in self.fields: assert field.name in self.__values, "Field %r is uninitialized" % (field.name,) value = self.__values[field.name] try: buffer += struct.pack(field.format, value) except struct.error as exc: raise struct.error("Error packing %r into %s.%s, %s" % (value, self.__class__.__name__, field.name, exc.message)) assert len(buffer) == self.size return buffer
def pack(self): buffer = "" for field in self.fields: try: buffer += struct.pack(field.format, value) except struct.error as exc: raise struct.error("Error packing %r into %s.%s, %s" % (value, self.__class__.__name__, field.name, exc.message)) assert len(buffer) == self.size return buffer
475,148
def pack(self): buffer = "" for field in self.fields: assert field.name in self.__values, "Field %r is uninitialized" % (field.name,) value = self.__values[field.name] try: buffer += struct.pack(field.format, value) except struct.error as exc: raise struct.error("Error packing %r into %s.%s, %s" % (value, self.__class__.__name__, field.name, exc.message)) assert len(buffer) == self.size return buffer
def pack(self): buffer = "" for field in self.fields: assert field.name in self.__values, "Field %r is uninitialized" % (field.name,) value = self.__values[field.name] try: value = (self.__values[field.name],) except KeyError: value = () try: buffer += struct.pack(field.format, *value) except struct.error as exc: raise struct.error("Error packing %r into %s.%s, %s" % (value, self.__class__.__name__, field.name, exc.message)) assert len(buffer) == self.size return buffer
475,149
def __repr__(self): return "<{0} {1}>".format(self.__class__.__name__, self.__values)
def __repr__(self): return "<{0} {1}>".format(self.__class__.__name__, self.__values)
475,150
def __repr__(self): return "<{0} {1}>".format(self.__class__.__name__, self.__values)
def __repr__(self): return "<{0} {1}>".format(self.__class__.__name__, self.__values)
475,151
def __repr__(self): return "<{0} {1}>".format(self.__class__.__name__, self.__values)
def __repr__(self): return "<{0} {1}>".format(self.__class__.__name__, self.__values)
475,152
def __repr__(self): return "<{0} {1}>".format(self.__class__.__name__, self.__values)
def __repr__(self): return "<{0} {1}>".format(self.__class__.__name__, self.__values)
475,153
def __init__(self, path=None, fileobj=None): assert bool(path) ^ bool(fileobj) if path: self.f = open(path, "r+b") else: self.f = fileobj self.f.seek(0) br = BootRecord.from_fileobj(self.f) assert br["ident"].rstrip("\0") == "clfs", repr(br["ident"]) assert br["version"] == 1 self.cluster_size = br["clrsize"] self.master_region_cluster_count = br["mstrclrs"] self.allocation_table_cluster_count = br["atabclrs"] self.data_region_cluster_count = br["dataclrs"] self.filesystem_cluster_count = \ self.master_region_cluster_count + \ self.allocation_table_cluster_count + \ self.data_region_cluster_count
def __init__(self, path): self.f = open(path, "r+b") br = BootRecord.from_fileobj(self.f) assert br["ident"].rstrip("\0") == "clfs", repr(br["ident"]) assert br["version"] == 1 self.cluster_size = br["clrsize"] self.master_region_cluster_count = br["mstrclrs"] self.allocation_table_cluster_count = br["atabclrs"] self.data_region_cluster_count = br["dataclrs"] self.filesystem_cluster_count = \ self.master_region_cluster_count + \ self.allocation_table_cluster_count + \ self.data_region_cluster_count
475,154
def __init__(self, path=None, fileobj=None): assert bool(path) ^ bool(fileobj) if path: self.f = open(path, "r+b") else: self.f = fileobj self.f.seek(0) br = BootRecord.from_fileobj(self.f) assert br["ident"].rstrip("\0") == "clfs", repr(br["ident"]) assert br["version"] == 1 self.cluster_size = br["clrsize"] self.master_region_cluster_count = br["mstrclrs"] self.allocation_table_cluster_count = br["atabclrs"] self.data_region_cluster_count = br["dataclrs"] self.filesystem_cluster_count = \ self.master_region_cluster_count + \ self.allocation_table_cluster_count + \ self.data_region_cluster_count
def __init__(self, path=None, fileobj=None): assert bool(path) ^ bool(fileobj) if path: self.f = open(path, "r+b") else: self.f = fileobj self.f.seek(0) br = BootRecord.from_fileobj(self.f) assert br["ident"].rstrip("\0") == "clfs", repr(br["ident"]) assert br["version"] == 1 self.cluster_size = br["clrsize"] self.master_region_cluster_count = br["mstrclrs"] self.allocation_table_cluster_count = br["atabclrs"] self.data_region_cluster_count = br["dataclrs"] @property def filesystem_cluster_count(self): return self.master_region_cluster_count + \ self.allocation_table_cluster_count + \ self.data_region_cluster_count
475,155
def read_directory(self, inode): inode_struct = self.get_inode_struct(inode) if inode_struct["type"] != TYPE_DIRECTORY: raise ClfsError(ENOTDIR) offset = 0 while offset < inode_struct["size"]: dirent = DirEntry.unpack(self.read_inode_data( inode, offset, DirEntry.size)) if dirent["name"].rstrip("\0"): yield dirent offset += dirent.size
def read_directory(self, inode): inode_struct = self.get_inode_struct(inode) if not S_ISDIR(inode_struct["mode"]): raise ClfsError(ENOTDIR) offset = 0 while offset < inode_struct["size"]: dirent = DirEntry.unpack(self.read_inode_data( inode, offset, DirEntry.size)) if dirent["name"].rstrip("\0"): yield dirent offset += dirent.size
475,156
def get_dir_entry(self, path): for name in path.split("/"): if not name: cur_dirent = self.get_root_dir_entry() else: # pdb.set_trace() for dirent in self.read_directory(cur_dirent["inode"]): if dirent["name"].rstrip("\0") == name: cur_dirent = dirent break else: raise ClfsError(ENOENT) return cur_dirent
def get_dir_entry(self, path): for name in path.split("/"): if not name: cur_dirent = self.get_root_dir_entry() else: # pdb.set_trace() for dirent in self.read_directory(cur_dirent["ino"]): if dirent["name"].rstrip("\0") == name: cur_dirent = dirent break else: raise ClfsError(ENOENT) return cur_dirent
475,157
def get_dir_entry(self, path): for name in path.split("/"): if not name: cur_dirent = self.get_root_dir_entry() else: # pdb.set_trace() for dirent in self.read_directory(cur_dirent["inode"]): if dirent["name"].rstrip("\0") == name: cur_dirent = dirent break else: raise ClfsError(ENOENT) return cur_dirent
def get_dir_entry(self, path): for name in path.split("/"): if not name: cur_dirent = self.get_root_dir_entry() else: # pdb.set_trace() for dirent in self.read_directory(cur_dirent["inode"]): if dirent["name"].rstrip("\0") == name: cur_dirent = dirent break else: raise ClfsError(ENOENT) return cur_dirent
475,158
#def write(self, path, buf, offset):
#def write(self, path, buf, offset):
475,159
def write_inode_data(self, inode, offset, buffer): inode_struct = self.get_inode_struct(inode) data_offset = inode_struct.size write_size, new_size = self.write_to_chain( inode, inode_struct["size"] + data_offset, offset + data_offset, buffer) assert write_size == len(buffer), write_size expected_size = data_offset + max(offset + write_size, inode_struct["size"]) assert new_size == expected_size, (new_size, expected_size) #assert new_size == # just update it anyway, i'll have to update times too inode_struct["size"] = new_size - data_offset #pdb.set_trace() assert (inode_struct.size, new_size) == self.write_to_chain( inode, new_size, 0, inode_struct.pack()) assert self.get_inode_struct(inode)["size"] == new_size - data_offset return write_size
def write_inode_data(self, ino, offset, buffer): inode_struct = self.get_inode_struct(inode) data_offset = inode_struct.size write_size, new_size = self.write_to_chain( ino, inode_struct["size"] + data_offset, offset + data_offset, buffer) assert write_size == len(buffer), write_size expected_size = data_offset + max(offset + write_size, inode_struct["size"]) assert new_size == expected_size, (new_size, expected_size) #assert new_size == # just update it anyway, i'll have to update times too inode_struct["size"] = new_size - data_offset #pdb.set_trace() assert (inode_struct.size, new_size) == self.write_to_chain( ino, new_size, 0, inode_struct.pack()) assert self.get_inode_struct(inode)["size"] == new_size - data_offset return write_size
475,160
def write_inode_data(self, inode, offset, buffer): inode_struct = self.get_inode_struct(inode) data_offset = inode_struct.size write_size, new_size = self.write_to_chain( inode, inode_struct["size"] + data_offset, offset + data_offset, buffer) assert write_size == len(buffer), write_size expected_size = data_offset + max(offset + write_size, inode_struct["size"]) assert new_size == expected_size, (new_size, expected_size) #assert new_size == # just update it anyway, i'll have to update times too inode_struct["size"] = new_size - data_offset #pdb.set_trace() assert (inode_struct.size, new_size) == self.write_to_chain( inode, new_size, 0, inode_struct.pack()) assert self.get_inode_struct(inode)["size"] == new_size - data_offset return write_size
def write_inode_data(self, inode, offset, buffer): inode_struct = self.get_inode_struct(inode) data_offset = inode_struct.size write_size, new_size = self.write_to_chain( inode, inode_struct["size"] + data_offset, offset + data_offset, buffer) assert write_size == len(buffer), write_size expected_size = data_offset + max(offset + write_size, inode_struct["size"]) assert new_size == expected_size, (new_size, expected_size) #assert new_size == # just update it anyway, i'll have to update times too inode_struct["size"] = new_size - data_offset #pdb.set_trace() assert (inode_struct.size, new_size) == self.write_to_chain( ino, new_size, 0, inode_struct.pack()) assert self.get_inode_struct(ino)["size"] == new_size - data_offset return write_size
475,161
def create_node(self, path, type): node_dirname, node_basename = os.path.split(path) parent_dirname, parent_basename = os.path.split(node_dirname) parent_dirent = self.get_dir_entry(node_dirname) parent_inode_struct = self.get_inode_struct(parent_dirent["inode"]) for dirent in self.read_directory(parent_dirent["inode"]): if dirent["name"].rstrip("\0") == node_basename: raise ClfsError(EEXIST) new_dirent = DirEntry(name=node_basename, inode=self.claim_free_cluster()) # write the new dirent at the end of the parent directory assert new_dirent.size == self.write_inode_data( parent_dirent["inode"], parent_inode_struct["size"], new_dirent.pack(),) # initialize the new inode #pdb.set_trace() new_inode = Inode(type=type, size=0) if type == TYPE_DIRECTORY: new_inode["links"] = 2 elif type == TYPE_REGULAR_FILE: new_inode["links"] = 1 assert (new_inode.size, new_inode.size) == self.write_to_chain( new_dirent["inode"], 0, 0, new_inode.pack())
def create_node(self, path, mode): """Create an allocate a new inode, update relevant structures elsewhere""" node_dirname, node_basename = os.path.split(path) parent_dirname, parent_basename = os.path.split(node_dirname) parent_dirent = self.get_dir_entry(node_dirname) parent_inode_struct = self.get_inode_struct(parent_dirent["inode"]) for dirent in self.read_directory(parent_dirent["inode"]): if dirent["name"].rstrip("\0") == node_basename: raise ClfsError(EEXIST) new_dirent = DirEntry(name=node_basename, inode=self.claim_free_cluster()) # write the new dirent at the end of the parent directory assert new_dirent.size == self.write_inode_data( parent_dirent["inode"], parent_inode_struct["size"], new_dirent.pack(),) # initialize the new inode #pdb.set_trace() new_inode = Inode(type=type, size=0) if type == TYPE_DIRECTORY: new_inode["links"] = 2 elif type == TYPE_REGULAR_FILE: new_inode["links"] = 1 assert (new_inode.size, new_inode.size) == self.write_to_chain( new_dirent["inode"], 0, 0, new_inode.pack())
475,162
def create_node(self, path, type): node_dirname, node_basename = os.path.split(path) parent_dirname, parent_basename = os.path.split(node_dirname) parent_dirent = self.get_dir_entry(node_dirname) parent_inode_struct = self.get_inode_struct(parent_dirent["inode"]) for dirent in self.read_directory(parent_dirent["inode"]): if dirent["name"].rstrip("\0") == node_basename: raise ClfsError(EEXIST) new_dirent = DirEntry(name=node_basename, inode=self.claim_free_cluster()) # write the new dirent at the end of the parent directory assert new_dirent.size == self.write_inode_data( parent_dirent["inode"], parent_inode_struct["size"], new_dirent.pack(),) # initialize the new inode #pdb.set_trace() new_inode = Inode(type=type, size=0) if type == TYPE_DIRECTORY: new_inode["links"] = 2 elif type == TYPE_REGULAR_FILE: new_inode["links"] = 1 assert (new_inode.size, new_inode.size) == self.write_to_chain( new_dirent["inode"], 0, 0, new_inode.pack())
def create_node(self, path, type): node_dirname, node_basename = os.path.split(path) parent_dirname, parent_basename = os.path.split(node_dirname) create_rootdir = bool( (not node_basename) and (node_dirname == parent_dirname == "/")) if create_rootdir: assert S_ISDIR(mode) new_inode = Inode(size=0, uid=0, gid=0, rdev=0, mode=mode) sec, nsec = time_as_posix_spec(time()) for field_name in ("atime", "mtime", "ctime"): new_inode[field_name] = sec for field_name in ("atimens", "mtimens", "ctimens"): new_inode[field_name] = nsec del sec, nsec if S_ISDIR(mode): new_inode["nlink"] = 2 else: new_inode["nlink"] = 1 new_dirent = DirEntry(ino=self.claim_free_cluster()) if create_rootdir: new_dirent["name"] = "/" assert new_dirent["ino"] == self.first_data_region_cluster_number, new_dirent["ino"] else: parent_ino = self.dirent_for_path(node_dirname)["ino"] for sibling_dirent in self.read_directory(parent_ino): if sibling_dirent["name"] == node_basename: raise ClfsError(EEXIST) else: new_dirent["name"] = node_basename assert (new_inode.size, new_inode.size) == self.write_to_chain( cluster=new_dirent["ino"], size=0, offset=0, buffer=new_inode.pack()) # write the new dirent at the end of the parent directory assert new_dirent.size == self.write_inode_data( parent_dirent["inode"], parent_inode_struct["size"], new_dirent.pack(),) # initialize the new inode #pdb.set_trace() new_inode = Inode(type=type, size=0) if type == TYPE_DIRECTORY: new_inode["links"] = 2 elif type == TYPE_REGULAR_FILE: new_inode["links"] = 1 assert (new_inode.size, new_inode.size) == self.write_to_chain( new_dirent["inode"], 0, 0, new_inode.pack())
475,163
def create_node(self, path, type): node_dirname, node_basename = os.path.split(path) parent_dirname, parent_basename = os.path.split(node_dirname) parent_dirent = self.get_dir_entry(node_dirname) parent_inode_struct = self.get_inode_struct(parent_dirent["inode"]) for dirent in self.read_directory(parent_dirent["inode"]): if dirent["name"].rstrip("\0") == node_basename: raise ClfsError(EEXIST) new_dirent = DirEntry(name=node_basename, inode=self.claim_free_cluster()) # write the new dirent at the end of the parent directory assert new_dirent.size == self.write_inode_data( parent_dirent["inode"], parent_inode_struct["size"], new_dirent.pack(),) # initialize the new inode #pdb.set_trace() new_inode = Inode(type=type, size=0) if type == TYPE_DIRECTORY: new_inode["links"] = 2 elif type == TYPE_REGULAR_FILE: new_inode["links"] = 1 assert (new_inode.size, new_inode.size) == self.write_to_chain( new_dirent["inode"], 0, 0, new_inode.pack())
def create_node(self, path, type): node_dirname, node_basename = os.path.split(path) parent_dirname, parent_basename = os.path.split(node_dirname) parent_dirent = self.get_dir_entry(node_dirname) parent_inode_struct = self.get_inode_struct(parent_dirent["inode"]) for dirent in self.read_directory(parent_dirent["inode"]): if dirent["name"].rstrip("\0") == node_basename: raise ClfsError(EEXIST) new_dirent = DirEntry(name=node_basename, inode=self.claim_free_cluster()) # write the new dirent at the end of the parent directory assert new_dirent.size == self.write_inode_data( parent_dirent["inode"], parent_inode_struct["size"], new_dirent.pack(),) # initialize the new inode #pdb.set_trace() new_inode = Inode(type=type, size=0) if type == TYPE_DIRECTORY: new_inode["links"] = 2 elif type == TYPE_REGULAR_FILE: new_inode["links"] = 1 assert (new_inode.size, new_inode.size) == self.write_to_chain( new_dirent["inode"], 0, 0, new_inode.pack())
475,164
def add_share(self, button): namelbl = gtk.Label("Share name:")
def add_share(self, button): namelbl = gtk.Label("Share name:")
475,165
def browse_peer_by_url(self, url): """Open the given peer URL with the most natural file manager for the current platform that we can find""" import os, subprocess if os.name == "nt": # this is how it's done programmatically? except that it won't invoke # the default file manager (explorer) on winders #ShellExecute(None, "explore", url, None, None, SW_SHOWNORMAL)
def browse_peer_by_url(self, url): """Open the given peer URL with the most natural file manager for the current platform that we can find""" import os, subprocess if os.name == "nt": # this is how it's done programmatically? except that it won't invoke # the default file manager (explorer) on winders #ShellExecute(None, "explore", url, None, None, SW_SHOWNORMAL)
475,166
def browse_peer_by_url(self, url): """Open the given peer URL with the most natural file manager for the current platform that we can find""" import os, subprocess if os.name == "nt": # this is how it's done programmatically? except that it won't invoke # the default file manager (explorer) on winders #ShellExecute(None, "explore", url, None, None, SW_SHOWNORMAL)
def browse_peer_by_url(self, url): """Open the given peer URL with the most natural file manager for the current platform that we can find""" import os, subprocess if os.name == "nt": # this is how it's done programmatically? except that it won't invoke # the default file manager (explorer) on winders #ShellExecute(None, "explore", url, None, None, SW_SHOWNORMAL)
475,167
def read_from_chain(self, first_cluster, chain_size, read_offset, read_size): if chain_size <= 0: return "" #assert read_offset + read_size <= chain_size, (read_offset, read_size, chain_size) if read_offset > self.cluster_size: return self.read_from_chain( self.next_cluster(first_cluster), chain_size - self.cluster_size, read_offset - self.cluster_size, read_size) cluster_read_size = min(read_size, self.cluster_size - read_offset) buffer = self.read_cluster(first_cluster, read_offset, cluster_read_size) assert len(buffer) == cluster_read_size return buffer + self.read_from_chain( self.next_cluster(first_cluster), chain_size - self.cluster_size, 0, read_size - cluster_read_size)
def read_from_chain(self, first_cluster, chain_size, read_offset, read_size): if chain_size <= 0: return "" #assert read_offset + read_size <= chain_size, (read_offset, read_size, chain_size) if read_offset > self.cluster_size: return self.read_from_chain( self.next_cluster(first_cluster), chain_size - self.cluster_size, read_offset - self.cluster_size, read_size) cluster_read_size = min(read_size, self.cluster_size - read_offset, chain_size) buffer = self.read_cluster(first_cluster, read_offset, cluster_read_size) assert len(buffer) == cluster_read_size return buffer + self.read_from_chain( self.next_cluster(first_cluster), chain_size - self.cluster_size, 0, read_size - cluster_read_size)
475,168
def trans_include(repo_uri, fargs, transaction=None): basedirs = [] timestamp_files = [] error_occurred = False opts, pargs = getopt.getopt(fargs, "d:T:") for opt, arg in opts: if opt == "-d": basedirs.append(arg) elif opt == "-T": timestamp_files.append(arg) if transaction == None: try: trans_id = os.environ["PKG_TRANS_ID"] except KeyError: usage(_("No transaction ID specified in $PKG_TRANS_ID"), cmd="include") xport, pub = setup_transport_and_pubs(repo_uri) t = trans.Transaction(repo_uri, trans_id=trans_id, xport=xport, pub=pub) else: t = transaction if not pargs: filelist = [("<stdin>", sys.stdin)] else: try: filelist = [(f, file(f)) for f in pargs] except IOError, e: error(e, cmd="include") return 1 lines = [] # giant string of all input files concatenated together linecnts = [] # tuples of starting line number, ending line number linecounter = 0 # running total for filename, f in filelist: try: data = f.read() except IOError, e: error(e, cmd="include") return 1 lines.append(data) linecnt = len(data.splitlines()) linecnts.append((linecounter, linecounter + linecnt)) linecounter += linecnt m = pkg.manifest.Manifest() try: m.set_content("\n".join(lines)) except apx.InvalidPackageErrors, err: e = err.errors[0] lineno = e.lineno for i, tup in enumerate(linecnts): if lineno > tup[0] and lineno <= tup[1]: filename = filelist[i][0] lineno -= tup[0] break else: filename = "???" lineno = "???" error(_("File %s line %s: %s") % (filename, lineno, e), cmd="include") return 1 invalid_action = False for a in m.gen_actions(): # don't publish this action if a.name == "set" and a.attrs["name"] in ["pkg.fmri", "fmri"]: continue elif a.name == "file": path, bd = pkg.actions.set_action_data( a.hash, a, basedirs) basename = os.path.basename(a.attrs["path"]) for pattern in timestamp_files: if fnmatch.fnmatch(basename, pattern): ts = pkg.misc.time_to_timestamp( os.stat(path).st_mtime) a.attrs["timestamp"] = ts break elif a.name == "license": pkg.actions.set_action_data(a.hash, a, basedirs) elif a.name in nopub_actions: error(_("invalid action for publication: %s") % str(a), cmd="include") invalid_action = True else: t.add(a) if invalid_action: return 3 else: return 0
def trans_include(repo_uri, fargs, transaction=None): basedirs = [] timestamp_files = [] error_occurred = False opts, pargs = getopt.getopt(fargs, "d:T:") for opt, arg in opts: if opt == "-d": basedirs.append(arg) elif opt == "-T": timestamp_files.append(arg) if transaction == None: try: trans_id = os.environ["PKG_TRANS_ID"] except KeyError: usage(_("No transaction ID specified in $PKG_TRANS_ID"), cmd="include") xport, pub = setup_transport_and_pubs(repo_uri) t = trans.Transaction(repo_uri, trans_id=trans_id, xport=xport, pub=pub) else: t = transaction if not pargs: filelist = [("<stdin>", sys.stdin)] else: try: filelist = [(f, file(f)) for f in pargs] except IOError, e: error(e, cmd="include") return 1 lines = [] # giant string of all input files concatenated together linecnts = [] # tuples of starting line number, ending line number linecounter = 0 # running total for filename, f in filelist: try: data = f.read() except IOError, e: error(e, cmd="include") return 1 lines.append(data) linecnt = len(data.splitlines()) linecnts.append((linecounter, linecounter + linecnt)) linecounter += linecnt m = pkg.manifest.Manifest() try: m.set_content("\n".join(lines)) except apx.InvalidPackageErrors, err: e = err.errors[0] lineno = e.lineno for i, tup in enumerate(linecnts): if lineno > tup[0] and lineno <= tup[1]: filename = filelist[i][0] lineno -= tup[0] break else: filename = "???" lineno = "???" error(_("File %s line %s: %s") % (filename, lineno, e), cmd="include") return 1 invalid_action = False for a in m.gen_actions(): # don't publish this action if a.name == "set" and a.attrs["name"] in ["pkg.fmri", "fmri"]: continue elif a.name == "file": path, bd = pkg.actions.set_action_data( a.hash, a, basedirs) basename = os.path.basename(a.attrs["path"]) for pattern in timestamp_files: if fnmatch.fnmatch(basename, pattern): ts = pkg.misc.time_to_timestamp( os.stat(path).st_mtime) a.attrs["timestamp"] = ts break elif a.name == "license": pkg.actions.set_action_data(a.hash, a, basedirs) if a.name in nopub_actions: error(_("invalid action for publication: %s") % str(a), cmd="include") invalid_action = True else: t.add(a) if invalid_action: return 3 else: return 0
475,169
def test_bug_12271_14088(self): """Check that consecutive duplicate lines are removed and that having a single option to -o still prints the header."""
def test_bug_12271_14088(self): """Check that consecutive duplicate lines are removed and that having a single option to -o still prints the header."""
475,170
def test_bug_12271_14088(self): """Check that consecutive duplicate lines are removed and that having a single option to -o still prints the header."""
def test_bug_12271_14088(self): """Check that consecutive duplicate lines are removed and that having a single option to -o still prints the header."""
475,171
def test_bug_12271_14088(self): """Check that consecutive duplicate lines are removed and that having a single option to -o still prints the header."""
def test_bug_12271_14088(self): """Check that consecutive duplicate lines are removed and that having a single option to -o still prints the header."""
475,172
def test_bug_12271_14088(self): """Check that consecutive duplicate lines are removed and that having a single option to -o still prints the header."""
def test_bug_12271_14088(self): """Check that consecutive duplicate lines are removed and that having a single option to -o still prints the header."""
475,173
def test_bug_12271_14088(self): """Check that consecutive duplicate lines are removed and that having a single option to -o still prints the header."""
def test_bug_12271_14088(self): """Check that consecutive duplicate lines are removed and that having a single option to -o still prints the header."""
475,174
def run(self): # nuke everything print("deleting " + dist_dir) shutil.rmtree(dist_dir, True) print("deleting " + build_dir) shutil.rmtree(build_dir, True) print("deleting " + root_dir) shutil.rmtree(root_dir, True) print("deleting " + pkgs_dir) shutil.rmtree(pkgs_dir, True) print("deleting " + extern_dir) shutil.rmtree(extern_dir, True)
def run(self): # nuke everything print("deleting " + dist_dir) shutil.rmtree(dist_dir, True) print("deleting " + build_dir) shutil.rmtree(build_dir, True) print("deleting " + root_dir) shutil.rmtree(root_dir, True) print("deleting " + pkgs_dir) shutil.rmtree(pkgs_dir, True) print("deleting " + extern_dir) shutil.rmtree(extern_dir, True)
475,175
def initialize_options(self): self.only = "" self.baselinefile = "" self.verbosemode = 0 self.parseable = 0 self.genbaseline = 0 self.timing = 0 self.coverage = 0 self.stoponerr = 0 self.debugoutput = 0 self.show_on_expected_fail = 0 self.startattest = "" self.archivedir = ""
def initialize_options(self): self.only = "" self.baselinefile = "" self.verbosemode = 0 self.parseable = 0 self.genbaseline = 0 self.timing = 0 self.coverage = 0 self.stoponerr = 0 self.debugoutput = 0 self.showonexpectedfail = 0 self.startattest = "" self.archivedir = ""
475,176
def main_func(): global cache_dir, download_start, xport, xport_cfg all_timestamps = False all_versions = False keep_compressed = False list_newest = False recursive = False src_uri = None target = None incoming_dir = None src_pub = None targ_pub = None temp_root = misc.config_temp_root() gettext.install("pkg", "/usr/share/locale") global_settings.client_name = "pkgrecv" target = os.environ.get("PKG_DEST", None) src_uri = os.environ.get("PKG_SRC", None) try: opts, pargs = getopt.getopt(sys.argv[1:], "c:d:hkm:nrs:") except getopt.GetoptError, e: usage(_("Illegal option -- %s") % e.opt) for opt, arg in opts: if opt == "-c": cache_dir = arg elif opt == "-d": target = arg elif opt == "-h": usage(retcode=0) elif opt == "-k": keep_compressed = True elif opt == "-n": list_newest = True elif opt == "-r": recursive = True elif opt == "-s": src_uri = arg elif opt == "-m": if arg == "all-timestamps": all_timestamps = True elif arg == "all-versions": all_versions = True else: usage(_("Illegal option value -- %s") % arg) if not src_uri: usage(_("a source repository must be provided")) if not cache_dir: cache_dir = tempfile.mkdtemp(dir=temp_root) # Only clean-up cache dir if implicitly created by pkgrecv. # User's cache-dirs should be preserved tmpdirs.append(cache_dir) incoming_dir = tempfile.mkdtemp(dir=temp_root) tmpdirs.append(incoming_dir) # Create transport and transport config xport, xport_cfg = transport.setup_transport() xport_cfg.cached_download_dir = cache_dir xport_cfg.incoming_download_dir = incoming_dir # Since publication destionations may only have one repository # configured per publisher, create destination as separate transport # in case source and destination have identical publisher configuration # but different repository endpoints. dest_xport, dest_xport_cfg = transport.setup_transport() dest_xport_cfg.cached_download_dir = cache_dir dest_xport_cfg.incoming_download_dir = incoming_dir # Configure src publisher src_pub = transport.setup_publisher(src_uri, "source", xport, xport_cfg, remote_publishers=True) tracker = get_tracker() if list_newest: if pargs or len(pargs) > 0: usage(_("-n takes no options")) fmri_list = fetch_catalog(src_pub, tracker, xport) list_newest_fmris(fmri_list) return 0 if pargs == None or len(pargs) == 0: usage(_("must specify at least one pkgfmri")) republish = False if not target: target = basedir = os.getcwd() elif target.find("://") != -1: basedir = tempfile.mkdtemp(dir=temp_root) tmpdirs.append(basedir) republish = True targ_pub = transport.setup_publisher(target, "target", dest_xport, dest_xport_cfg, remote_publishers=True) # Files have to be decompressed for republishing. keep_compressed = False if target.startswith("file://"): # Check to see if the repository exists first. try: t = trans.Transaction(target, xport=dest_xport, pub=targ_pub) except trans.TransactionRepositoryInvalidError, e: txt = str(e) + "\n\n" txt += _("To create a repository, use the " "pkgsend command.") abort(err=txt) except trans.TransactionRepositoryConfigError, e: txt = str(e) + "\n\n" txt += _("The repository configuration for " "the repository located at '%s' is not " "valid or the specified path does not " "exist. Please correct the configuration " "of the repository or create a new " "one.") % target abort(err=txt) except trans.TransactionError, e: abort(err=e) else: basedir = target if not os.path.exists(basedir): try: os.makedirs(basedir, misc.PKG_DIR_MODE) except: error(_("Unable to create basedir '%s'.") % \ basedir) return 1 xport_cfg.pkgdir = basedir if republish: targ_fmris = fetch_catalog(targ_pub, tracker, dest_xport) all_fmris = fetch_catalog(src_pub, tracker, xport) fmri_arguments = pargs fmri_list = prune(list(set(expand_matching_fmris(all_fmris, fmri_arguments))), all_versions, all_timestamps) if recursive: msg(_("Retrieving manifests for dependency evaluation ...")) tracker.evaluate_start() fmri_list = prune(get_dependencies(src_uri, fmri_list, basedir, tracker), all_versions, all_timestamps) tracker.evaluate_done() def get_basename(pfmri): open_time = pfmri.get_timestamp() return "%d_%s" % \ (calendar.timegm(open_time.utctimetuple()), urllib.quote(str(pfmri), "")) # First, retrieve the manifests and calculate package transfer sizes. npkgs = len(fmri_list) nfiles = 0 nbytes = 0 if not recursive: msg(_("Retrieving manifests for package evaluation ...")) tracker.evaluate_start(npkgs=npkgs) retrieve_list = [] while fmri_list: f = fmri_list.pop() if republish and f in targ_fmris: msg(_("Skipping %s: already present " "at destination") % f) continue m = get_manifest(f, basedir) pkgdir = os.path.join(basedir, f.get_dir_path()) mfile = xport.multi_file_ni(src_pub, pkgdir, not keep_compressed, tracker) nf, nb = add_hashes_to_multi(m, mfile) nfiles += nf nbytes += nb retrieve_list.append((f, mfile)) tracker.evaluate_progress(fmri=f) tracker.evaluate_done() # Next, retrieve and store the content for each package. msg(_("Retrieving package content ...")) tracker.download_set_goal(len(retrieve_list), nfiles, nbytes) publish_list = [] while retrieve_list: f, mfile = retrieve_list.pop() tracker.download_start_pkg(f.get_fmri(include_scheme=False)) if mfile: mfile.wait_files() if not download_start: download_start = True if republish: publish_list.append(f) tracker.download_end_pkg() tracker.download_done() tracker.reset() # Finally, republish the packages if needed. while publish_list: f = publish_list.pop() msg(_("Republishing %s ...") % f) m = get_manifest(f, basedir) # Get first line of original manifest so that inclusion of the # scheme can be determined. use_scheme = True contents = get_manifest(f, basedir, contents=True) if contents.splitlines()[0].find("pkg:/") == -1: use_scheme = False pkg_name = f.get_fmri(include_scheme=use_scheme) pkgdir = os.path.join(basedir, f.get_dir_path()) # This is needed so any previous failures for a package # can be aborted. trans_id = get_basename(f) if not targ_pub: targ_pub = transport.setup_publisher(target, "target", dest_xport, dest_xport_cfg, remote_publishers=True) try: t = trans.Transaction(target, pkg_name=pkg_name, trans_id=trans_id, xport=dest_xport, pub=targ_pub) # Remove any previous failed attempt to # to republish this package. try: t.close(abandon=True) except: # It might not exist already. pass t.open() for a in m.gen_actions(): if a.name == "set" and \ a.attrs.get("name", "") in ("fmri", "pkg.fmri"): # To be consistent with the server, # the fmri can't be added to the # manifest. continue if hasattr(a, "hash"): fname = os.path.join(pkgdir, a.hash) a.data = lambda: open(fname, "rb") t.add(a) t.close() except trans.TransactionError, e: abort(err=e) return 1 # Dump all temporary data. cleanup() return 0
def main_func(): global cache_dir, download_start, xport, xport_cfg all_timestamps = False all_versions = False keep_compressed = False list_newest = False recursive = False src_uri = None target = None incoming_dir = None src_pub = None targ_pub = None temp_root = misc.config_temp_root() gettext.install("pkg", "/usr/share/locale") global_settings.client_name = "pkgrecv" target = os.environ.get("PKG_DEST", None) src_uri = os.environ.get("PKG_SRC", None) try: opts, pargs = getopt.getopt(sys.argv[1:], "c:d:hkm:nrs:") except getopt.GetoptError, e: usage(_("Illegal option -- %s") % e.opt) for opt, arg in opts: if opt == "-c": cache_dir = arg elif opt == "-d": target = arg elif opt == "-h": usage(retcode=0) elif opt == "-k": keep_compressed = True elif opt == "-n": list_newest = True elif opt == "-r": recursive = True elif opt == "-s": src_uri = arg elif opt == "-m": if arg == "all-timestamps": all_timestamps = True elif arg == "all-versions": all_versions = True else: usage(_("Illegal option value -- %s") % arg) if not src_uri: usage(_("a source repository must be provided")) if not cache_dir: cache_dir = tempfile.mkdtemp(dir=temp_root) # Only clean-up cache dir if implicitly created by pkgrecv. # User's cache-dirs should be preserved tmpdirs.append(cache_dir) incoming_dir = tempfile.mkdtemp(dir=temp_root) tmpdirs.append(incoming_dir) # Create transport and transport config xport, xport_cfg = transport.setup_transport() xport_cfg.cached_download_dir = cache_dir xport_cfg.incoming_download_dir = incoming_dir # Since publication destionations may only have one repository # configured per publisher, create destination as separate transport # in case source and destination have identical publisher configuration # but different repository endpoints. dest_xport, dest_xport_cfg = transport.setup_transport() dest_xport_cfg.cached_download_dir = cache_dir dest_xport_cfg.incoming_download_dir = incoming_dir # Configure src publisher src_pub = transport.setup_publisher(src_uri, "source", xport, xport_cfg, remote_prefix=True) tracker = get_tracker() if list_newest: if pargs or len(pargs) > 0: usage(_("-n takes no options")) fmri_list = fetch_catalog(src_pub, tracker, xport) list_newest_fmris(fmri_list) return 0 if pargs == None or len(pargs) == 0: usage(_("must specify at least one pkgfmri")) republish = False if not target: target = basedir = os.getcwd() elif target.find("://") != -1: basedir = tempfile.mkdtemp(dir=temp_root) tmpdirs.append(basedir) republish = True targ_pub = transport.setup_publisher(target, "target", dest_xport, dest_xport_cfg, remote_prefix=True) # Files have to be decompressed for republishing. keep_compressed = False if target.startswith("file://"): # Check to see if the repository exists first. try: t = trans.Transaction(target, xport=dest_xport, pub=targ_pub) except trans.TransactionRepositoryInvalidError, e: txt = str(e) + "\n\n" txt += _("To create a repository, use the " "pkgsend command.") abort(err=txt) except trans.TransactionRepositoryConfigError, e: txt = str(e) + "\n\n" txt += _("The repository configuration for " "the repository located at '%s' is not " "valid or the specified path does not " "exist. Please correct the configuration " "of the repository or create a new " "one.") % target abort(err=txt) except trans.TransactionError, e: abort(err=e) else: basedir = target if not os.path.exists(basedir): try: os.makedirs(basedir, misc.PKG_DIR_MODE) except: error(_("Unable to create basedir '%s'.") % \ basedir) return 1 xport_cfg.pkgdir = basedir if republish: targ_fmris = fetch_catalog(targ_pub, tracker, dest_xport) all_fmris = fetch_catalog(src_pub, tracker, xport) fmri_arguments = pargs fmri_list = prune(list(set(expand_matching_fmris(all_fmris, fmri_arguments))), all_versions, all_timestamps) if recursive: msg(_("Retrieving manifests for dependency evaluation ...")) tracker.evaluate_start() fmri_list = prune(get_dependencies(src_uri, fmri_list, basedir, tracker), all_versions, all_timestamps) tracker.evaluate_done() def get_basename(pfmri): open_time = pfmri.get_timestamp() return "%d_%s" % \ (calendar.timegm(open_time.utctimetuple()), urllib.quote(str(pfmri), "")) # First, retrieve the manifests and calculate package transfer sizes. npkgs = len(fmri_list) nfiles = 0 nbytes = 0 if not recursive: msg(_("Retrieving manifests for package evaluation ...")) tracker.evaluate_start(npkgs=npkgs) retrieve_list = [] while fmri_list: f = fmri_list.pop() if republish and f in targ_fmris: msg(_("Skipping %s: already present " "at destination") % f) continue m = get_manifest(f, basedir) pkgdir = os.path.join(basedir, f.get_dir_path()) mfile = xport.multi_file_ni(src_pub, pkgdir, not keep_compressed, tracker) nf, nb = add_hashes_to_multi(m, mfile) nfiles += nf nbytes += nb retrieve_list.append((f, mfile)) tracker.evaluate_progress(fmri=f) tracker.evaluate_done() # Next, retrieve and store the content for each package. msg(_("Retrieving package content ...")) tracker.download_set_goal(len(retrieve_list), nfiles, nbytes) publish_list = [] while retrieve_list: f, mfile = retrieve_list.pop() tracker.download_start_pkg(f.get_fmri(include_scheme=False)) if mfile: mfile.wait_files() if not download_start: download_start = True if republish: publish_list.append(f) tracker.download_end_pkg() tracker.download_done() tracker.reset() # Finally, republish the packages if needed. while publish_list: f = publish_list.pop() msg(_("Republishing %s ...") % f) m = get_manifest(f, basedir) # Get first line of original manifest so that inclusion of the # scheme can be determined. use_scheme = True contents = get_manifest(f, basedir, contents=True) if contents.splitlines()[0].find("pkg:/") == -1: use_scheme = False pkg_name = f.get_fmri(include_scheme=use_scheme) pkgdir = os.path.join(basedir, f.get_dir_path()) # This is needed so any previous failures for a package # can be aborted. trans_id = get_basename(f) if not targ_pub: targ_pub = transport.setup_publisher(target, "target", dest_xport, dest_xport_cfg, remote_prefix=True) try: t = trans.Transaction(target, pkg_name=pkg_name, trans_id=trans_id, xport=dest_xport, pub=targ_pub) # Remove any previous failed attempt to # to republish this package. try: t.close(abandon=True) except: # It might not exist already. pass t.open() for a in m.gen_actions(): if a.name == "set" and \ a.attrs.get("name", "") in ("fmri", "pkg.fmri"): # To be consistent with the server, # the fmri can't be added to the # manifest. continue if hasattr(a, "hash"): fname = os.path.join(pkgdir, a.hash) a.data = lambda: open(fname, "rb") t.add(a) t.close() except trans.TransactionError, e: abort(err=e) return 1 # Dump all temporary data. cleanup() return 0
475,177
def main_func(): global cache_dir, download_start, xport, xport_cfg all_timestamps = False all_versions = False keep_compressed = False list_newest = False recursive = False src_uri = None target = None incoming_dir = None src_pub = None targ_pub = None temp_root = misc.config_temp_root() gettext.install("pkg", "/usr/share/locale") global_settings.client_name = "pkgrecv" target = os.environ.get("PKG_DEST", None) src_uri = os.environ.get("PKG_SRC", None) try: opts, pargs = getopt.getopt(sys.argv[1:], "c:d:hkm:nrs:") except getopt.GetoptError, e: usage(_("Illegal option -- %s") % e.opt) for opt, arg in opts: if opt == "-c": cache_dir = arg elif opt == "-d": target = arg elif opt == "-h": usage(retcode=0) elif opt == "-k": keep_compressed = True elif opt == "-n": list_newest = True elif opt == "-r": recursive = True elif opt == "-s": src_uri = arg elif opt == "-m": if arg == "all-timestamps": all_timestamps = True elif arg == "all-versions": all_versions = True else: usage(_("Illegal option value -- %s") % arg) if not src_uri: usage(_("a source repository must be provided")) if not cache_dir: cache_dir = tempfile.mkdtemp(dir=temp_root) # Only clean-up cache dir if implicitly created by pkgrecv. # User's cache-dirs should be preserved tmpdirs.append(cache_dir) incoming_dir = tempfile.mkdtemp(dir=temp_root) tmpdirs.append(incoming_dir) # Create transport and transport config xport, xport_cfg = transport.setup_transport() xport_cfg.cached_download_dir = cache_dir xport_cfg.incoming_download_dir = incoming_dir # Since publication destionations may only have one repository # configured per publisher, create destination as separate transport # in case source and destination have identical publisher configuration # but different repository endpoints. dest_xport, dest_xport_cfg = transport.setup_transport() dest_xport_cfg.cached_download_dir = cache_dir dest_xport_cfg.incoming_download_dir = incoming_dir # Configure src publisher src_pub = transport.setup_publisher(src_uri, "source", xport, xport_cfg, remote_publishers=True) tracker = get_tracker() if list_newest: if pargs or len(pargs) > 0: usage(_("-n takes no options")) fmri_list = fetch_catalog(src_pub, tracker, xport) list_newest_fmris(fmri_list) return 0 if pargs == None or len(pargs) == 0: usage(_("must specify at least one pkgfmri")) republish = False if not target: target = basedir = os.getcwd() elif target.find("://") != -1: basedir = tempfile.mkdtemp(dir=temp_root) tmpdirs.append(basedir) republish = True targ_pub = transport.setup_publisher(target, "target", dest_xport, dest_xport_cfg, remote_publishers=True) # Files have to be decompressed for republishing. keep_compressed = False if target.startswith("file://"): # Check to see if the repository exists first. try: t = trans.Transaction(target, xport=dest_xport, pub=targ_pub) except trans.TransactionRepositoryInvalidError, e: txt = str(e) + "\n\n" txt += _("To create a repository, use the " "pkgsend command.") abort(err=txt) except trans.TransactionRepositoryConfigError, e: txt = str(e) + "\n\n" txt += _("The repository configuration for " "the repository located at '%s' is not " "valid or the specified path does not " "exist. Please correct the configuration " "of the repository or create a new " "one.") % target abort(err=txt) except trans.TransactionError, e: abort(err=e) else: basedir = target if not os.path.exists(basedir): try: os.makedirs(basedir, misc.PKG_DIR_MODE) except: error(_("Unable to create basedir '%s'.") % \ basedir) return 1 xport_cfg.pkgdir = basedir if republish: targ_fmris = fetch_catalog(targ_pub, tracker, dest_xport) all_fmris = fetch_catalog(src_pub, tracker, xport) fmri_arguments = pargs fmri_list = prune(list(set(expand_matching_fmris(all_fmris, fmri_arguments))), all_versions, all_timestamps) if recursive: msg(_("Retrieving manifests for dependency evaluation ...")) tracker.evaluate_start() fmri_list = prune(get_dependencies(src_uri, fmri_list, basedir, tracker), all_versions, all_timestamps) tracker.evaluate_done() def get_basename(pfmri): open_time = pfmri.get_timestamp() return "%d_%s" % \ (calendar.timegm(open_time.utctimetuple()), urllib.quote(str(pfmri), "")) # First, retrieve the manifests and calculate package transfer sizes. npkgs = len(fmri_list) nfiles = 0 nbytes = 0 if not recursive: msg(_("Retrieving manifests for package evaluation ...")) tracker.evaluate_start(npkgs=npkgs) retrieve_list = [] while fmri_list: f = fmri_list.pop() if republish and f in targ_fmris: msg(_("Skipping %s: already present " "at destination") % f) continue m = get_manifest(f, basedir) pkgdir = os.path.join(basedir, f.get_dir_path()) mfile = xport.multi_file_ni(src_pub, pkgdir, not keep_compressed, tracker) nf, nb = add_hashes_to_multi(m, mfile) nfiles += nf nbytes += nb retrieve_list.append((f, mfile)) tracker.evaluate_progress(fmri=f) tracker.evaluate_done() # Next, retrieve and store the content for each package. msg(_("Retrieving package content ...")) tracker.download_set_goal(len(retrieve_list), nfiles, nbytes) publish_list = [] while retrieve_list: f, mfile = retrieve_list.pop() tracker.download_start_pkg(f.get_fmri(include_scheme=False)) if mfile: mfile.wait_files() if not download_start: download_start = True if republish: publish_list.append(f) tracker.download_end_pkg() tracker.download_done() tracker.reset() # Finally, republish the packages if needed. while publish_list: f = publish_list.pop() msg(_("Republishing %s ...") % f) m = get_manifest(f, basedir) # Get first line of original manifest so that inclusion of the # scheme can be determined. use_scheme = True contents = get_manifest(f, basedir, contents=True) if contents.splitlines()[0].find("pkg:/") == -1: use_scheme = False pkg_name = f.get_fmri(include_scheme=use_scheme) pkgdir = os.path.join(basedir, f.get_dir_path()) # This is needed so any previous failures for a package # can be aborted. trans_id = get_basename(f) if not targ_pub: targ_pub = transport.setup_publisher(target, "target", dest_xport, dest_xport_cfg, remote_publishers=True) try: t = trans.Transaction(target, pkg_name=pkg_name, trans_id=trans_id, xport=dest_xport, pub=targ_pub) # Remove any previous failed attempt to # to republish this package. try: t.close(abandon=True) except: # It might not exist already. pass t.open() for a in m.gen_actions(): if a.name == "set" and \ a.attrs.get("name", "") in ("fmri", "pkg.fmri"): # To be consistent with the server, # the fmri can't be added to the # manifest. continue if hasattr(a, "hash"): fname = os.path.join(pkgdir, a.hash) a.data = lambda: open(fname, "rb") t.add(a) t.close() except trans.TransactionError, e: abort(err=e) return 1 # Dump all temporary data. cleanup() return 0
def main_func(): global cache_dir, download_start, xport, xport_cfg all_timestamps = False all_versions = False keep_compressed = False list_newest = False recursive = False src_uri = None target = None incoming_dir = None src_pub = None targ_pub = None temp_root = misc.config_temp_root() gettext.install("pkg", "/usr/share/locale") global_settings.client_name = "pkgrecv" target = os.environ.get("PKG_DEST", None) src_uri = os.environ.get("PKG_SRC", None) try: opts, pargs = getopt.getopt(sys.argv[1:], "c:d:hkm:nrs:") except getopt.GetoptError, e: usage(_("Illegal option -- %s") % e.opt) for opt, arg in opts: if opt == "-c": cache_dir = arg elif opt == "-d": target = arg elif opt == "-h": usage(retcode=0) elif opt == "-k": keep_compressed = True elif opt == "-n": list_newest = True elif opt == "-r": recursive = True elif opt == "-s": src_uri = arg elif opt == "-m": if arg == "all-timestamps": all_timestamps = True elif arg == "all-versions": all_versions = True else: usage(_("Illegal option value -- %s") % arg) if not src_uri: usage(_("a source repository must be provided")) if not cache_dir: cache_dir = tempfile.mkdtemp(dir=temp_root) # Only clean-up cache dir if implicitly created by pkgrecv. # User's cache-dirs should be preserved tmpdirs.append(cache_dir) incoming_dir = tempfile.mkdtemp(dir=temp_root) tmpdirs.append(incoming_dir) # Create transport and transport config xport, xport_cfg = transport.setup_transport() xport_cfg.cached_download_dir = cache_dir xport_cfg.incoming_download_dir = incoming_dir # Since publication destionations may only have one repository # configured per publisher, create destination as separate transport # in case source and destination have identical publisher configuration # but different repository endpoints. dest_xport, dest_xport_cfg = transport.setup_transport() dest_xport_cfg.cached_download_dir = cache_dir dest_xport_cfg.incoming_download_dir = incoming_dir # Configure src publisher src_pub = transport.setup_publisher(src_uri, "source", xport, xport_cfg, remote_publishers=True) tracker = get_tracker() if list_newest: if pargs or len(pargs) > 0: usage(_("-n takes no options")) fmri_list = fetch_catalog(src_pub, tracker, xport) list_newest_fmris(fmri_list) return 0 if pargs == None or len(pargs) == 0: usage(_("must specify at least one pkgfmri")) republish = False if not target: target = basedir = os.getcwd() elif target.find("://") != -1: basedir = tempfile.mkdtemp(dir=temp_root) tmpdirs.append(basedir) republish = True targ_pub = transport.setup_publisher(target, "target", dest_xport, dest_xport_cfg, remote_prefix=True) # Files have to be decompressed for republishing. keep_compressed = False if target.startswith("file://"): # Check to see if the repository exists first. try: t = trans.Transaction(target, xport=dest_xport, pub=targ_pub) except trans.TransactionRepositoryInvalidError, e: txt = str(e) + "\n\n" txt += _("To create a repository, use the " "pkgsend command.") abort(err=txt) except trans.TransactionRepositoryConfigError, e: txt = str(e) + "\n\n" txt += _("The repository configuration for " "the repository located at '%s' is not " "valid or the specified path does not " "exist. Please correct the configuration " "of the repository or create a new " "one.") % target abort(err=txt) except trans.TransactionError, e: abort(err=e) else: basedir = target if not os.path.exists(basedir): try: os.makedirs(basedir, misc.PKG_DIR_MODE) except: error(_("Unable to create basedir '%s'.") % \ basedir) return 1 xport_cfg.pkgdir = basedir if republish: targ_fmris = fetch_catalog(targ_pub, tracker, dest_xport) all_fmris = fetch_catalog(src_pub, tracker, xport) fmri_arguments = pargs fmri_list = prune(list(set(expand_matching_fmris(all_fmris, fmri_arguments))), all_versions, all_timestamps) if recursive: msg(_("Retrieving manifests for dependency evaluation ...")) tracker.evaluate_start() fmri_list = prune(get_dependencies(src_uri, fmri_list, basedir, tracker), all_versions, all_timestamps) tracker.evaluate_done() def get_basename(pfmri): open_time = pfmri.get_timestamp() return "%d_%s" % \ (calendar.timegm(open_time.utctimetuple()), urllib.quote(str(pfmri), "")) # First, retrieve the manifests and calculate package transfer sizes. npkgs = len(fmri_list) nfiles = 0 nbytes = 0 if not recursive: msg(_("Retrieving manifests for package evaluation ...")) tracker.evaluate_start(npkgs=npkgs) retrieve_list = [] while fmri_list: f = fmri_list.pop() if republish and f in targ_fmris: msg(_("Skipping %s: already present " "at destination") % f) continue m = get_manifest(f, basedir) pkgdir = os.path.join(basedir, f.get_dir_path()) mfile = xport.multi_file_ni(src_pub, pkgdir, not keep_compressed, tracker) nf, nb = add_hashes_to_multi(m, mfile) nfiles += nf nbytes += nb retrieve_list.append((f, mfile)) tracker.evaluate_progress(fmri=f) tracker.evaluate_done() # Next, retrieve and store the content for each package. msg(_("Retrieving package content ...")) tracker.download_set_goal(len(retrieve_list), nfiles, nbytes) publish_list = [] while retrieve_list: f, mfile = retrieve_list.pop() tracker.download_start_pkg(f.get_fmri(include_scheme=False)) if mfile: mfile.wait_files() if not download_start: download_start = True if republish: publish_list.append(f) tracker.download_end_pkg() tracker.download_done() tracker.reset() # Finally, republish the packages if needed. while publish_list: f = publish_list.pop() msg(_("Republishing %s ...") % f) m = get_manifest(f, basedir) # Get first line of original manifest so that inclusion of the # scheme can be determined. use_scheme = True contents = get_manifest(f, basedir, contents=True) if contents.splitlines()[0].find("pkg:/") == -1: use_scheme = False pkg_name = f.get_fmri(include_scheme=use_scheme) pkgdir = os.path.join(basedir, f.get_dir_path()) # This is needed so any previous failures for a package # can be aborted. trans_id = get_basename(f) if not targ_pub: targ_pub = transport.setup_publisher(target, "target", dest_xport, dest_xport_cfg, remote_prefix=True) try: t = trans.Transaction(target, pkg_name=pkg_name, trans_id=trans_id, xport=dest_xport, pub=targ_pub) # Remove any previous failed attempt to # to republish this package. try: t.close(abandon=True) except: # It might not exist already. pass t.open() for a in m.gen_actions(): if a.name == "set" and \ a.attrs.get("name", "") in ("fmri", "pkg.fmri"): # To be consistent with the server, # the fmri can't be added to the # manifest. continue if hasattr(a, "hash"): fname = os.path.join(pkgdir, a.hash) a.data = lambda: open(fname, "rb") t.add(a) t.close() except trans.TransactionError, e: abort(err=e) return 1 # Dump all temporary data. cleanup() return 0
475,178
def get_basename(pfmri): open_time = pfmri.get_timestamp() return "%d_%s" % \ (calendar.timegm(open_time.utctimetuple()), urllib.quote(str(pfmri), ""))
def get_basename(pfmri): open_time = pfmri.get_timestamp() return "%d_%s" % \ (calendar.timegm(open_time.utctimetuple()), urllib.quote(str(pfmri), ""))
475,179
def get_publisherinfo(self, pub, ccancel=None): """Given a publisher pub, return the publisher/0 information in a StringIO object."""
def get_publisherinfo(self, pub, ccancel=None): """Given a publisher pub, return the publisher/0 information in a StringIO object."""
475,180
def main_func(): global file_repo global def_branch global def_repo global def_vers global extra_entire_contents global just_these_pkgs global not_these_pkgs global nopublish global publish_all global print_pkg_names global reference_uris global show_debug global wos_path global not_these_consolidations global curpkg try: _opts, _args = getopt.getopt(sys.argv[1:], "AB:C:D:E:I:J:G:NR:T:b:dj:m:ns:v:w:p:") except getopt.GetoptError, _e: print "unknown option", _e.opt sys.exit(1) g_proto_area = os.environ.get("ROOT", "") for opt, arg in _opts: if opt == "-b": def_branch = arg.rstrip("abcdefghijklmnopqrstuvwxyz") elif opt == "-d": show_debug = True elif opt == "-j": # means we're using the new argument form... just_these_pkgs.append(arg) elif opt == "-m": _a = arg.split("=", 1) set_macro(_a[0], _a[1]) elif opt == "-n": nopublish = True elif opt == "-p": if not os.path.exists(arg): raise RuntimeError("Invalid prototype area specified.") # Clean up relative ../../, etc. out of path to proto g_proto_area = os.path.realpath(arg) elif opt == "-s": def_repo = arg if def_repo.startswith("file://"): file_repo = True elif opt == "-v": def_vers = arg elif opt == "-w": wos_path.append(arg) elif opt == "-A": # Always publish obsoleted and renamed packages. publish_all = True elif opt == "-B": branch_file = file(arg) for _line in branch_file: if not _line.startswith("#"): bfargs = _line.split() if len(bfargs) == 2: branch_dict[bfargs[0]] = bfargs[1] branch_file.close() elif opt == "-C": not_these_consolidations.append(arg) elif opt == "-D": elided_files[arg] = True elif opt == "-E": if "@" not in arg: print "-E fmris require a version: %s" % arg sys.exit(2) extra_entire_contents.append(arg) elif opt == "-I": include_path.extend(arg.split(":")) elif opt == "-J": not_these_pkgs.append(arg) elif opt == "-G": #another file of global includes global_includes.append(arg) elif opt == "-N": print_pkg_names = True elif opt == "-R": reference_uris.append(arg) elif opt == "-T": timestamp_files.append(arg) if not def_branch: print "need a branch id (build number)" sys.exit(2) elif "." not in def_branch: print "branch id needs to be of the form 'x.y'" sys.exit(2) if not _args: print "need argument!" sys.exit(2) if not wos_path: wos_path = def_wos_path if just_these_pkgs: filelist = _args else: filelist = _args[0:1] just_these_pkgs = _args[1:] if print_pkg_names: for _mf in filelist: SolarisParse(_mf) sys.exit(0) start_time = time.clock() print "First pass: initial import", datetime.now() for _mf in filelist: SolarisParse(_mf) # Remove pkgs we're not touching because we're skipping that # consolidation pkgs_to_elide = [ p.name for p in pkgdict.values() if p.consolidation in not_these_consolidations ] for pkg in pkgs_to_elide: del pkgdict[pkg] for pkg in not_these_pkgs: del pkgdict[pkg] # Unless we are publishing all obsolete and renamed packages # (-A command line option), remove obsolete and renamed packages # that weren't obsoleted or renamed at this branch and create # a dictionary (called or_pkgs_per_con) of obsoleted and renamed # packages per consolidation. The version portion of the fmri # will contain the branch that the package was obsoleted or renamed at. or_pkgs_per_con = {} obs_or_renamed_pkgs = {} for pkg in pkgdict.keys(): obs_branch = pkgdict[pkg].obsolete_branch rename_branch = pkgdict[pkg].rename_branch ver_tokens = pkgdict[pkg].version.split(".") cons = pkgdict[pkg].consolidation if obs_branch: ver_tokens[-1] = obs_branch ver_string = ".".join(ver_tokens) or_pkgs_per_con.setdefault(cons, {})[pkg] = ver_string obs_or_renamed_pkgs[pkg] = (pkgdict[pkg].fmristr(), "obsolete") if publish_all: pkgdict[pkg].version = ver_string else: if obs_branch != def_branch.split(".")[1]: # Not publishing this obsolete package. del pkgdict[pkg] if rename_branch: ver_tokens[-1] = rename_branch ver_string = ".".join(ver_tokens) or_pkgs_per_con.setdefault(cons, {})[pkg] = ver_string obs_or_renamed_pkgs[pkg] = (pkgdict[pkg].fmristr(), "renamed") if publish_all: pkgdict[pkg].version = ver_string else: if rename_branch != def_branch.split(".")[1]: # Not publishing this renamed package. del pkgdict[pkg] print "Second pass: global crosschecks", datetime.now() # perform global crosschecks # path_dict.clear() for pkg in pkgdict.values(): for action in pkg.actions: if "path" not in action.attrs: continue path = action.attrs["path"] path_dict.setdefault(path, []).append(action) if action.name in ["file", "link", "hardlink"]: basename_dict.setdefault(os.path.basename(path), []).append(action) pkgpath_dict.setdefault(path, []).append(action.attrs["importer.ipspkg"]) errors = check_pathdict_actions(path_dict) if errors: for e in errors: print "Fail: %s" % e sys.exit(1) # check for require dependencies on obsolete or renamed pkgs errors = [] warns = [] for pack in pkgdict.values(): for action in pack.actions: if action.name != "depend": continue if action.attrs["type"] == "require" and "fmri" in action.attrs: fmri = action.attrs["fmri"].split("@")[0] # remove version if fmri.startswith("pkg:/"): # remove pkg:/ if exists fmri = fmri[5:] if fmri in obs_or_renamed_pkgs: tup = obs_or_renamed_pkgs[fmri] s = "Pkg %s has 'require' dependency on pkg %s, which is %s" % ( (pack.fmristr(),) + tup) if tup[1] == "obsolete": errors.append(s) else: warns.append(s) if warns: for w in warns: print "Warn: %s" % w if errors: for e in errors: print "Fail: %s" % e sys.exit(1) print "packages being published are self consistent" if reference_uris: print "downloading and checking external references" excludes = [variant.Variants({"variant.arch": get_arch()}).allow_action] for uri in reference_uris: server, fmri_string = uri.split("@", 1) for pfmri in get_dependencies(server, [fmri_string]): if pfmri.get_name() in pkgdict: continue # ignore pkgs already seen pfmri_str = "%s@%s" % (pfmri.get_name(), pfmri.get_version()) fmridict[pfmri.get_name()] = pfmri_str for action in get_manifest(server, pfmri).gen_actions(excludes): if "path" not in action.attrs: continue if action.name == "unknown": # we don't care about unknown actions - # mispublished packages with eg. SVR4 # pkginfo files result in duplicate paths, # causing errors in check_pathdict_actions # "Multiple actions on different types # with the same path" print "INFO: ignoring action in %s: %s" \ % (pfmri_str, str(action)) continue action.attrs["importer.ipspkg"] = pfmri_str path_dict.setdefault(action.attrs["path"], []).append(action) if action.name in ["file", "link", "hardlink"]: basename_dict.setdefault(os.path.basename( action.attrs["path"]), []).append(action) pkgpath_dict.setdefault(action.attrs["path"], []).append(action.attrs["importer.ipspkg"]) errors = check_pathdict_actions(path_dict) if errors: for e in errors: print "Fail: %s" % e sys.exit(1) print "external packages checked for conflicts" print "Third pass: dependency id, resolution and publication", datetime.now() consolidation_incorporations = [] obsoleted_renamed_pkgs = [] # Generate consolidation incorporations for cons in cons_dict.keys(): if cons in not_these_consolidations: print "skipping consolidation %s" % cons continue consolidation_incorporation = "consolidation/%s/%s-incorporation" % ( cons, cons) consolidation_incorporations.append(consolidation_incorporation) curpkg = start_package(consolidation_incorporation) curpkg.summary = "%s consolidation incorporation" % cons curpkg.desc = "This incorporation constrains packages " \ "from the %s consolidation." % cons # Add packages that aren't renamed or obsoleted or_pkgs = or_pkgs_per_con.get(cons, {}) curpkg.actions.append(actions.fromstr( "set name=pkg.depend.install-hold value=core-os.%s" % cons)) for depend in cons_dict[cons]: if depend not in or_pkgs: action = actions.fromstr( "depend fmri=%s type=incorporate" % depend) action.attrs["importer.source"] = "depend" curpkg.actions.append(action) # Add in the obsoleted and renamed packages for this # consolidation. for name, version in or_pkgs.iteritems(): action = actions.fromstr( "depend fmri=%s@%s type=incorporate" % (name, version)) action.attrs["importer.source"] = "depend" curpkg.actions.append(action) obsoleted_renamed_pkgs.append("%s@%s" % (name, version)) action = actions.fromstr("set " \ "name=org.opensolaris.consolidation value=%s" % cons) action.attrs["importer.source"] = "add" curpkg.actions.append(action) end_package(curpkg) curpkg = None # Generate entire consolidation if we're generating any consolidation incorps if consolidation_incorporations: curpkg = start_package("entire") curpkg.summary = "incorporation to lock all system packages to same build" curpkg.desc = "This package constrains " \ "system package versions to the same build. WARNING: Proper " \ "system update and correct package selection depend on the " \ "presence of this incorporation. Removing this package will " \ "result in an unsupported system." curpkg.actions.append(actions.fromstr( "set name=pkg.depend.install-hold value=core-os")) for incorp in consolidation_incorporations: action = actions.fromstr("depend fmri=%s type=incorporate" % incorp) action.attrs["importer.source"] = "auto-generated" curpkg.actions.append(action) action = actions.fromstr("depend fmri=%s type=require" % incorp) action.attrs["importer.source"] = "auto-generated" action.attrs["importer.no-version"] = "true" curpkg.actions.append(action) for extra in extra_entire_contents: action = actions.fromstr("depend fmri=%s type=incorporate" % extra) action.attrs["importer.source"] = "command-line" curpkg.actions.append(action) extra_noversion = extra.split("@")[0] # remove version action = actions.fromstr("depend fmri=%s type=require" % extra_noversion) action.attrs["importer.source"] = "command-line" action.attrs["importer.no-version"] = "true" curpkg.actions.append(action) end_package(curpkg) curpkg = None incorporated_pkgs = set([ f for l in cons_dict.values() for f in l ]) incorporated_pkgs |= set(consolidation_incorporations) incorporated_pkgs |= set(["entire", "redistributable"]) incorporated_pkgs |= set(obsoleted_renamed_pkgs) unincorps = set(pkgdict.keys()) - incorporated_pkgs if unincorps: # look through these; if they have only set actions they're # ancient obsoleted pkgs - ignore them. for f in unincorps.copy(): for a in pkgdict[f].actions: if a.name != "set": break else: unincorps.remove(f) print "The following non-empty unincorporated pkgs are not part of any consolidation" for f in unincorps: print f if just_these_pkgs: newpkgs = set(pkgdict[name] for name in pkgdict.keys() if name in just_these_pkgs ) else: newpkgs = set(pkgdict.values()) if not_these_pkgs: newpkgs = set(pkgdict[name] for name in pkgdict.keys() if name not in not_these_pkgs ) else: newpkgs = set(pkgdict.values()) if not_these_consolidations: newpkgs = set([ p for p in newpkgs if not p.delivered_via_ips() ]) processed = 0 total = len(newpkgs) error_count = 0 for _p in sorted(newpkgs): if show_debug: print " Version:", _p.version print " Description:", _p.desc print " Summary:", _p.summary print " Classification:", ",".join(_p.classification) try: publish_pkg(_p) except trans.TransactionError, _e: print "%s: FAILED: %s\n" % (_p.name, _e) error_count += 1 processed += 1 if show_debug: print "%d/%d packages processed; %.2f%% complete" % (processed, total, processed * 100.0 / total) if error_count: print "%d/%d packages has errors; %.2f%% FAILED" % (error_count, total, error_count * 100.0 / total) sys.exit(1) print "%d/%d packages processed; %.2f%% complete" % (processed, total, processed * 100.0 / total) if file_repo: code = repo_add_content(def_repo[7:], g_proto_area) if code: sys.exit(code) print "Done:", datetime.now() elapsed = time.clock() - start_time print "publication took %d:%.2d" % (elapsed/60, elapsed % 60) sys.exit(0)
def main_func(): global file_repo global def_branch global def_repo global def_vers global extra_entire_contents global just_these_pkgs global not_these_pkgs global nopublish global publish_all global print_pkg_names global reference_uris global show_debug global wos_path global not_these_consolidations global curpkg try: _opts, _args = getopt.getopt(sys.argv[1:], "AB:C:D:E:I:J:G:NR:T:b:dj:m:ns:v:w:p:") except getopt.GetoptError, _e: print "unknown option", _e.opt sys.exit(1) g_proto_area = os.environ.get("ROOT", "") for opt, arg in _opts: if opt == "-b": def_branch = arg.rstrip("abcdefghijklmnopqrstuvwxyz") elif opt == "-d": show_debug = True elif opt == "-j": # means we're using the new argument form... just_these_pkgs.append(arg) elif opt == "-m": _a = arg.split("=", 1) set_macro(_a[0], _a[1]) elif opt == "-n": nopublish = True elif opt == "-p": if not os.path.exists(arg): raise RuntimeError("Invalid prototype area specified.") # Clean up relative ../../, etc. out of path to proto g_proto_area = os.path.realpath(arg) elif opt == "-s": def_repo = arg if def_repo.startswith("file://"): file_repo = True elif opt == "-v": def_vers = arg elif opt == "-w": wos_path.append(arg) elif opt == "-A": # Always publish obsoleted and renamed packages. publish_all = True elif opt == "-B": branch_file = file(arg) for _line in branch_file: if not _line.startswith("#"): bfargs = _line.split() if len(bfargs) == 2: branch_dict[bfargs[0]] = bfargs[1] branch_file.close() elif opt == "-C": not_these_consolidations.append(arg) elif opt == "-D": elided_files[arg] = True elif opt == "-E": if "@" not in arg: print "-E fmris require a version: %s" % arg sys.exit(2) extra_entire_contents.append(arg) elif opt == "-I": include_path.extend(arg.split(":")) elif opt == "-J": not_these_pkgs.append(arg) elif opt == "-G": #another file of global includes global_includes.append(arg) elif opt == "-N": print_pkg_names = True elif opt == "-R": reference_uris.append(arg) elif opt == "-T": timestamp_files.append(arg) if not def_branch: print "need a branch id (build number)" sys.exit(2) elif "." not in def_branch: print "branch id needs to be of the form 'x.y'" sys.exit(2) if not _args: print "need argument!" sys.exit(2) if not wos_path: wos_path = def_wos_path if just_these_pkgs: filelist = _args else: filelist = _args[0:1] just_these_pkgs = _args[1:] if print_pkg_names: for _mf in filelist: SolarisParse(_mf) sys.exit(0) start_time = time.clock() print "First pass: initial import", datetime.now() for _mf in filelist: SolarisParse(_mf) # Remove pkgs we're not touching because we're skipping that # consolidation pkgs_to_elide = [ p.name for p in pkgdict.values() if p.consolidation in not_these_consolidations ] for pkg in pkgs_to_elide: del pkgdict[pkg] for pkg in not_these_pkgs: del pkgdict[pkg] # Unless we are publishing all obsolete and renamed packages # (-A command line option), remove obsolete and renamed packages # that weren't obsoleted or renamed at this branch and create # a dictionary (called or_pkgs_per_con) of obsoleted and renamed # packages per consolidation. The version portion of the fmri # will contain the branch that the package was obsoleted or renamed at. or_pkgs_per_con = {} obs_or_renamed_pkgs = {} for pkg in pkgdict.keys(): obs_branch = pkgdict[pkg].obsolete_branch rename_branch = pkgdict[pkg].rename_branch ver_tokens = pkgdict[pkg].version.split(".") cons = pkgdict[pkg].consolidation if obs_branch: ver_tokens[-1] = obs_branch ver_string = ".".join(ver_tokens) or_pkgs_per_con.setdefault(cons, {})[pkg] = ver_string obs_or_renamed_pkgs[pkg] = (pkgdict[pkg].fmristr(), "obsolete") if publish_all: pkgdict[pkg].version = ver_string else: if obs_branch != def_branch.split(".")[1]: # Not publishing this obsolete package. del pkgdict[pkg] if rename_branch: ver_tokens[-1] = rename_branch ver_string = ".".join(ver_tokens) or_pkgs_per_con.setdefault(cons, {})[pkg] = ver_string obs_or_renamed_pkgs[pkg] = (pkgdict[pkg].fmristr(), "renamed") if publish_all: pkgdict[pkg].version = ver_string else: if rename_branch != def_branch.split(".")[1]: # Not publishing this renamed package. del pkgdict[pkg] print "Second pass: global crosschecks", datetime.now() # perform global crosschecks # path_dict.clear() for pkg in pkgdict.values(): for action in pkg.actions: if "path" not in action.attrs: continue path = action.attrs["path"] path_dict.setdefault(path, []).append(action) if action.name in ["file", "link", "hardlink"]: basename_dict.setdefault(os.path.basename(path), []).append(action) pkgpath_dict.setdefault(path, []).append(action.attrs["importer.ipspkg"]) errors = check_pathdict_actions(path_dict) if errors: for e in errors: print "Fail: %s" % e sys.exit(1) # check for require dependencies on obsolete or renamed pkgs errors = [] warns = [] for pack in pkgdict.values(): for action in pack.actions: if action.name != "depend": continue if action.attrs["type"] == "require" and "fmri" in action.attrs: fmri = action.attrs["fmri"].split("@")[0] # remove version if fmri.startswith("pkg:/"): # remove pkg:/ if exists fmri = fmri[5:] if fmri in obs_or_renamed_pkgs: tup = obs_or_renamed_pkgs[fmri] s = "Pkg %s has 'require' dependency on pkg %s, which is %s" % ( (pack.fmristr(),) + tup) if tup[1] == "obsolete": errors.append(s) else: warns.append(s) if warns: for w in warns: print "Warn: %s" % w if errors: for e in errors: print "Fail: %s" % e sys.exit(1) print "packages being published are self consistent" if reference_uris: print "downloading and checking external references" excludes = [variant.Variants({"variant.arch": get_arch()}).allow_action] for uri in reference_uris: server, fmri_string = uri.split("@", 1) for pfmri in get_dependencies(server, [fmri_string]): if pfmri.get_name() in pkgdict: continue # ignore pkgs already seen pfmri_str = "%s@%s" % (pfmri.get_name(), pfmri.get_version()) fmridict[pfmri.get_name()] = pfmri_str for action in get_manifest(server, pfmri).gen_actions(excludes): if "path" not in action.attrs: continue if action.name == "unknown": # we don't care about unknown actions - # mispublished packages with eg. SVR4 # pkginfo files result in duplicate paths, # causing errors in check_pathdict_actions # "Multiple actions on different types # with the same path" print "INFO: ignoring action in %s: %s" \ % (pfmri_str, str(action)) continue action.attrs["importer.ipspkg"] = pfmri_str path_dict.setdefault(action.attrs["path"], []).append(action) if action.name in ["file", "link", "hardlink"]: basename_dict.setdefault(os.path.basename( action.attrs["path"]), []).append(action) pkgpath_dict.setdefault(action.attrs["path"], []).append(action.attrs["importer.ipspkg"]) errors = check_pathdict_actions(path_dict) if errors: for e in errors: print "Fail: %s" % e sys.exit(1) print "external packages checked for conflicts" print "Third pass: dependency id, resolution and publication", datetime.now() consolidation_incorporations = [] obsoleted_renamed_pkgs = [] # Generate consolidation incorporations for cons in cons_dict.keys(): if cons in not_these_consolidations: print "skipping consolidation %s" % cons continue consolidation_incorporation = "consolidation/%s/%s-incorporation" % ( cons, cons) consolidation_incorporations.append(consolidation_incorporation) curpkg = start_package(consolidation_incorporation) curpkg.summary = "%s consolidation incorporation" % cons curpkg.desc = "This incorporation constrains packages " \ "from the %s consolidation." % cons # Add packages that aren't renamed or obsoleted or_pkgs = or_pkgs_per_con.get(cons, {}) curpkg.actions.append(actions.fromstr( "set name=pkg.depend.install-hold value=core-os.%s" % cons)) for depend in cons_dict[cons]: if depend not in or_pkgs: action = actions.fromstr( "depend fmri=%s type=incorporate" % depend) action.attrs["importer.source"] = "depend" curpkg.actions.append(action) # Add in the obsoleted and renamed packages for this # consolidation. for name, version in or_pkgs.iteritems(): action = actions.fromstr( "depend fmri=%s@%s type=incorporate" % (name, version)) action.attrs["importer.source"] = "depend" curpkg.actions.append(action) obsoleted_renamed_pkgs.append("%s@%s" % (name, version)) action = actions.fromstr("set " \ "name=org.opensolaris.consolidation value=%s" % cons) action.attrs["importer.source"] = "add" curpkg.actions.append(action) end_package(curpkg) curpkg = None # Generate entire consolidation if we're generating any consolidation incorps if consolidation_incorporations: curpkg = start_package("entire") curpkg.summary = "incorporation to lock all system packages to same build" curpkg.desc = "This package constrains " \ "system package versions to the same build. WARNING: Proper " \ "system update and correct package selection depend on the " \ "presence of this incorporation. Removing this package will " \ "result in an unsupported system." curpkg.actions.append(actions.fromstr( "set name=pkg.depend.install-hold value=core-os")) for incorp in consolidation_incorporations: action = actions.fromstr("depend fmri=%s type=incorporate" % incorp) action.attrs["importer.source"] = "auto-generated" curpkg.actions.append(action) action = actions.fromstr("depend fmri=%s type=require" % incorp) action.attrs["importer.source"] = "auto-generated" action.attrs["importer.no-version"] = "true" curpkg.actions.append(action) for extra in extra_entire_contents: action = actions.fromstr("depend fmri=%s type=incorporate" % extra) action.attrs["importer.source"] = "command-line" curpkg.actions.append(action) extra_noversion = extra.split("@")[0] # remove version action = actions.fromstr("depend fmri=%s type=require" % extra_noversion) action.attrs["importer.source"] = "command-line" action.attrs["importer.no-version"] = "true" curpkg.actions.append(action) end_package(curpkg) curpkg = None incorporated_pkgs = set([ f for l in cons_dict.values() for f in l ]) incorporated_pkgs |= set(consolidation_incorporations) incorporated_pkgs |= set(["entire", "redistributable"]) incorporated_pkgs |= set(obsoleted_renamed_pkgs) unincorps = set(pkgdict.keys()) - incorporated_pkgs if unincorps: # look through these; if they have only set actions they're # ancient obsoleted pkgs - ignore them. for f in unincorps.copy(): for a in pkgdict[f].actions: if a.name != "set": break else: unincorps.remove(f) print "The following non-empty unincorporated pkgs are not part of any consolidation" for f in unincorps: print f if just_these_pkgs: newpkgs = set(pkgdict[name] for name in pkgdict.keys() if name in just_these_pkgs ) else: newpkgs = set(pkgdict.values()) if not_these_consolidations: newpkgs = set([ p for p in newpkgs if not p.delivered_via_ips() ]) processed = 0 total = len(newpkgs) error_count = 0 for _p in sorted(newpkgs): if show_debug: print " Version:", _p.version print " Description:", _p.desc print " Summary:", _p.summary print " Classification:", ",".join(_p.classification) try: publish_pkg(_p) except trans.TransactionError, _e: print "%s: FAILED: %s\n" % (_p.name, _e) error_count += 1 processed += 1 if show_debug: print "%d/%d packages processed; %.2f%% complete" % (processed, total, processed * 100.0 / total) if error_count: print "%d/%d packages has errors; %.2f%% FAILED" % (error_count, total, error_count * 100.0 / total) sys.exit(1) print "%d/%d packages processed; %.2f%% complete" % (processed, total, processed * 100.0 / total) if file_repo: code = repo_add_content(def_repo[7:], g_proto_area) if code: sys.exit(code) print "Done:", datetime.now() elapsed = time.clock() - start_time print "publication took %d:%.2d" % (elapsed/60, elapsed % 60) sys.exit(0)
475,181
def get_smf_packages(server_url, manifest_locations, filter): """ Performs a search against server_url looking for packages which contain SMF manifests, returning a list of those pfmris """ dir = os.getcwd() tracker = pkg.client.progress.QuietProgressTracker() image_dir = tempfile.mkdtemp("", "pkg_importer_smfsearch.") is_zone = False pub_name = "opensolaris.org" refresh_allowed = True # create a temporary image api_inst = pkg.client.api.image_create(PKG_CLIENT_NAME, CLIENT_API_VERSION, image_dir, pkg.client.api.IMG_TYPE_USER, is_zone, facets=pkg.facet.Facets(), force=False, prefix=pub_name, progtrack=tracker, refresh_allowed=refresh_allowed, repo_uri=server_url) api_inst = pkg.client.api.ImageInterface(image_dir, pkg.client.api.CURRENT_API_VERSION, tracker, None, PKG_CLIENT_NAME) # restore the current directory, which ImageInterace had changed os.chdir(dir) searches = [] fmris = set() case_sensitive = False return_actions = True query = [] for manifest_loc in manifest_locations: query.append(pkg.client.api.Query(":directory:path:/%s" % manifest_loc, case_sensitive, return_actions)) searches.append(api_inst.remote_search(query)) shutil.rmtree(image_dir, True) for item in searches: for result in item: pfmri = None try: query_num, pub, (v, return_type, tmp) = result pfmri, index, action = tmp except ValueError: raise if pfmri is None: continue if filter in pfmri.get_fmri(): fmris.add(pfmri.get_fmri()) return [pkg.fmri.PkgFmri(pfmri) for pfmri in fmris]
def get_smf_packages(server_url, manifest_locations, filter): """ Performs a search against server_url looking for packages which contain SMF manifests, returning a list of those pfmris """ dir = os.getcwd() tracker = pkg.client.progress.QuietProgressTracker() image_dir = tempfile.mkdtemp("", "pkg_importer_smfsearch.") is_zone = False refresh_allowed = True # create a temporary image api_inst = pkg.client.api.image_create(PKG_CLIENT_NAME, CLIENT_API_VERSION, image_dir, pkg.client.api.IMG_TYPE_USER, is_zone, facets=pkg.facet.Facets(), force=False, prefix=pub_name, progtrack=tracker, refresh_allowed=refresh_allowed, repo_uri=server_url) api_inst = pkg.client.api.ImageInterface(image_dir, pkg.client.api.CURRENT_API_VERSION, tracker, None, PKG_CLIENT_NAME) # restore the current directory, which ImageInterace had changed os.chdir(dir) searches = [] fmris = set() case_sensitive = False return_actions = True query = [] for manifest_loc in manifest_locations: query.append(pkg.client.api.Query(":directory:path:/%s" % manifest_loc, case_sensitive, return_actions)) searches.append(api_inst.remote_search(query)) shutil.rmtree(image_dir, True) for item in searches: for result in item: pfmri = None try: query_num, pub, (v, return_type, tmp) = result pfmri, index, action = tmp except ValueError: raise if pfmri is None: continue if filter in pfmri.get_fmri(): fmris.add(pfmri.get_fmri()) return [pkg.fmri.PkgFmri(pfmri) for pfmri in fmris]
475,182
def get_smf_packages(server_url, manifest_locations, filter): """ Performs a search against server_url looking for packages which contain SMF manifests, returning a list of those pfmris """ dir = os.getcwd() tracker = pkg.client.progress.QuietProgressTracker() image_dir = tempfile.mkdtemp("", "pkg_importer_smfsearch.") is_zone = False pub_name = "opensolaris.org" refresh_allowed = True # create a temporary image api_inst = pkg.client.api.image_create(PKG_CLIENT_NAME, CLIENT_API_VERSION, image_dir, pkg.client.api.IMG_TYPE_USER, is_zone, facets=pkg.facet.Facets(), force=False, prefix=pub_name, progtrack=tracker, refresh_allowed=refresh_allowed, repo_uri=server_url) api_inst = pkg.client.api.ImageInterface(image_dir, pkg.client.api.CURRENT_API_VERSION, tracker, None, PKG_CLIENT_NAME) # restore the current directory, which ImageInterace had changed os.chdir(dir) searches = [] fmris = set() case_sensitive = False return_actions = True query = [] for manifest_loc in manifest_locations: query.append(pkg.client.api.Query(":directory:path:/%s" % manifest_loc, case_sensitive, return_actions)) searches.append(api_inst.remote_search(query)) shutil.rmtree(image_dir, True) for item in searches: for result in item: pfmri = None try: query_num, pub, (v, return_type, tmp) = result pfmri, index, action = tmp except ValueError: raise if pfmri is None: continue if filter in pfmri.get_fmri(): fmris.add(pfmri.get_fmri()) return [pkg.fmri.PkgFmri(pfmri) for pfmri in fmris]
def get_smf_packages(server_url, manifest_locations, filter): """ Performs a search against server_url looking for packages which contain SMF manifests, returning a list of those pfmris """ dir = os.getcwd() tracker = pkg.client.progress.QuietProgressTracker() image_dir = tempfile.mkdtemp("", "pkg_importer_smfsearch.") is_zone = False pub_name = "opensolaris.org" refresh_allowed = True # create a temporary image api_inst = pkg.client.api.image_create(PKG_CLIENT_NAME, CLIENT_API_VERSION, image_dir, pkg.client.api.IMG_TYPE_USER, is_zone, facets=pkg.facet.Facets(), force=False, progtrack=tracker, refresh_allowed=refresh_allowed, repo_uri=server_url) api_inst = pkg.client.api.ImageInterface(image_dir, pkg.client.api.CURRENT_API_VERSION, tracker, None, PKG_CLIENT_NAME) # restore the current directory, which ImageInterace had changed os.chdir(dir) searches = [] fmris = set() case_sensitive = False return_actions = True query = [] for manifest_loc in manifest_locations: query.append(pkg.client.api.Query(":directory:path:/%s" % manifest_loc, case_sensitive, return_actions)) searches.append(api_inst.remote_search(query)) shutil.rmtree(image_dir, True) for item in searches: for result in item: pfmri = None try: query_num, pub, (v, return_type, tmp) = result pfmri, index, action = tmp except ValueError: raise if pfmri is None: continue if filter in pfmri.get_fmri(): fmris.add(pfmri.get_fmri()) return [pkg.fmri.PkgFmri(pfmri) for pfmri in fmris]
475,183
def set_function_fields(self, cursor, user, id, name, value, arg, context=None): request_obj = self.pool.get('res.request') req_ref_obj = self.pool.get('res.request.reference')
def set_function_fields(self, cursor, user, id, name, value, arg, context=None): request_obj = self.pool.get('res.request') req_ref_obj = self.pool.get('res.request.reference')
475,184
def add_minutes(self, cursor, user, company, date, minutes, context=None): minutes = int(round(minutes)) minutes = date.minute + minutes
def add_minutes(self, cursor, user, company, date, minutes, context=None): minutes = int(round(minutes)) minutes = date.minute + minutes
475,185
def add_hours(self, cursor, user, company, date, hours, context=None): day_per_week = company.hours_per_work_week / company.hours_per_work_day
def add_hours(self, cursor, user, company, date, hours, context=None): day_per_week = company.hours_per_work_week / company.hours_per_work_day
475,186
def add_days(self, cursor, user, company, date, days, context=None): day_per_week = company.hours_per_work_week / company.hours_per_work_day
def add_days(self, cursor, user, company, date, days, context=None): day_per_week = company.hours_per_work_week / company.hours_per_work_day
475,187
def add_weeks(self, cursor, user, company, date, weeks, context=None): day_per_week = company.hours_per_work_week / company.hours_per_work_day
def add_weeks(self, cursor, user, company, date, weeks, context=None): day_per_week = company.hours_per_work_week / company.hours_per_work_day
475,188
def get_function_fields(self, ids, names): ''' Function to compute function fields
def get_function_fields(self, ids, names): ''' Function to compute function fields
475,189
def test0005views(self): ''' Test views. ''' self.assertRaises(Exception, test_view('project_plan'))
def test0005views(self): ''' Test views. ''' self.assertRaises(Exception, test_view('project_plan'))
475,190
def set_function_fields(self, cursor, user, ids, name, value, context=None): request_obj = self.pool.get('res.request') req_ref_obj = self.pool.get('res.request.reference')
def set_function_fields(self, cursor, user, ids, name, value, context=None): request_obj = self.pool.get('res.request') req_ref_obj = self.pool.get('res.request.reference')
475,191
def log_job_closed(self): log.info("Job finished: Ticket:%s Task:%s User:%s Start:%f End:%f Time:%f Price:%f State:%s" % (self.ticket(), self.task(), self.getUser(), self.jobStart(), self.jobEnd(), self.getTime(), self.getCost(), self.getState()))
def log_job_closed(self): log.info("Job finished: Ticket:%s Task:%s User:%s Start:%f End:%f Time:%f Price:%f State:%s" % (self.ticket(), self.task(), self.getUser(), self.jobStart(), self.jobEnd(), self.getTime(), self.getCost(), self.getState()))
475,192
def __init__(self, ticket_id, id, mgr): """Initialize a new task.""" TaskFSM.__init__(self) self.mtx = self.fsm.getLock()
def __init__(self, ticket_id, id, mgr): """Initialize a new task.""" TaskFSM.__init__(self) self.mtx = self.fsm.getLock()
475,193
def cleanUp(self): """cleans up the task, i.e. removes the task's spool directory""" self.log.info("removing spool directory") from xbe.util import removeDirCompletely removeDirCompletely(self.__spool)
def cleanUp(self): """cleans up the task, i.e. removes the task's spool directory""" self.log.info("removing spool directory") from xbe.util import removeDirCompletely removeDirCompletely(self.__spool)
475,194
def getState(self): return self.__fsm.getState().getName()
def getState(self): return self.__fsm.getState().getName()
475,195
def do_Event(self, event, reqCtxt): log.debug("JOB '%s' run in state '%s' event '%s'" % (self.ticket(), self.__fsm.getState().getName(), event)) if hasattr(self.__fsm, event): log.debug("Run event '%s'" % event) getattr(self.__fsm, event)(self, reqCtxt) else: log.debug("Event '%s' not found." % event) raise CommandFailed("jobFSM: No such Transition '%s'." % event)
def do_Event(self, event, reqCtxt): log.debug("JOB '%s' run in state '%s' event '%s'" % (self.ticket(), self.__fsm.getState().getName(), event)) if hasattr(self.__fsm, event): log.debug("Run event '%s'" % event) getattr(self.__fsm, event)(self, reqCtxt) else: log.error("Event '%s' not found." % event) raise CommandFailed("jobFSM: No such Transition '%s'." % event)
475,196
def do_EventByMap(self, eventkey, reqCtxt): eventMap = { "Pending:Reserved" : 1, "Pending:Confirmed" : "confirm", "Running:Stage-In" : "runJob_StageIn", "Running:Instance-Starting" : "", "Running:Executing" : "runJob_Execute", "Running:Stage-Out" : "runJob_StageOut", "Running:Instance-Stopping" : "", "Finished" : "closeJob_Closing",
def do_EventByMap(self, eventkey, reqCtxt): eventMap = { "Pending:Reserved" : 1, "Pending:Confirmed" : "confirm", "Running:Stage-In" : "runJob_StageIn", "Running:Instance-Starting" : "", "Running:Executing" : "runJob_Execute", "Running:Stage-Out" : "runJob_StageOut", "Running:Instance-Stopping" : "", "Finished" : "closeJob_Closing",
475,197
def do_EventByMap(self, eventkey, reqCtxt): eventMap = { "Pending:Reserved" : 1, "Pending:Confirmed" : "confirm", "Running:Stage-In" : "runJob_StageIn", "Running:Instance-Starting" : "", "Running:Executing" : "runJob_Execute", "Running:Stage-Out" : "runJob_StageOut", "Running:Instance-Stopping" : "", "Finished" : "closeJob_Closing",
def do_EventByMap(self, eventkey, reqCtxt): eventMap = { "Pending:Reserved" : 1, "Pending:Confirmed" : "confirm", "Running:Stage-In" : "runJob_StageIn", "Running:Instance-Starting" : "", "Running:Executing" : "runJob_Execute", "Running:Stage-Out" : "runJob_StageOut", "Running:Instance-Stopping" : "", "Finished" : "closeJob_Closing",
475,198
def log_job_closed(self): log.info("Job finished: Ticket:%s Task:%s User:%s Start:%f End:%f Time:%f Price:%f State:%s" % (self.ticket(), self.task(), self.getUser(), self.getStart(), self.getEnd(), self.getTime(), self.getCost(), self.getState()))
def log_job_closed(self): log.info("Job finished: Ticket:%s Task:%s User:%s Start:%f End:%f Time:%f Price:%f State:%s" % (self.ticket(), self.task(), self.getUser(), self.getStart(), self.getEnd(), self.getTime(), self.getCost(), self.getState()))
475,199