rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
print "\t-d, --download_dir\t\t\tOverride the default download directory"
print "\t-d, --download_dir\t\tOverride the default download directory"
def usage(): print "sofabuddy.py [options]" print 'Example' print '\tsofabuddy.py -d "/media/downloads" -h "192.168.1.1"' print "Options" print "\t-?, --help\t\t\tWill bring up this message" print "\t-d, --download_dir\t\t\tOverride the default download directory" print "\t-h, --host=HOST\t\t\tChoose the ip address of ...
print 'IDENTIFIED:', log_line, 'FILE:', filename
print timestamp(), 'IDENTIFIED:', log_line, 'FILE:', filename
def getfileinfo(filename): fileext = os.path.splitext(filename) results = re.search('s[0-9][0-9]e[0-9][0-9]', filename, re.I) try: sxxexx = results.group(0) snum = sxxexx[1:3] enum = sxxexx[4:6] except: try: results = re.search('[0-9][0-9]x[0-9][0-9]', filename, re.I) sxxexx = results.group(0) snum = sxxexx[0:2] enum ...
os.makedirs(sdir[0]) shutil.move(origfilename, newpath) os.symlink(newpath, origfilename) else: for nukefile in os.listdir(sdir[0]): XXxXX = snum + 'x' + enum if nukefile.find(XXxXX) > 0: fullnukepath = os.path.join(sdir[0], nukefile) nukemoveto = os.path.join(nuke_dir, nukefile) nukemoveorigto = os.path.join(nuke_dir,...
os.makedirs(sdir[0])
def do_file_move(showid, showname, snum, enum, epname, quality, fileext, origfilename): season_dir = 'Season ' + snum episode_filename = '[' + snum + 'x' + enum + ']' + ' ' + epname + ' [' + quality + ']' + fileext newpath = os.path.join(tv_dir, showname, season_dir, episode_filename) sdir = os.path.split(newpath) i...
is_locked = open(lockfile) print 'ERROR: tvwrangler.py is locked'
is_locked = open(lockfile) print timestamp(), 'ERROR: tvwrangler.py is locked'
def do_file_move(showid, showname, snum, enum, epname, quality, fileext, origfilename): season_dir = 'Season ' + snum episode_filename = '[' + snum + 'x' + enum + ']' + ' ' + epname + ' [' + quality + ']' + fileext newpath = os.path.join(tv_dir, showname, season_dir, episode_filename) sdir = os.path.split(newpath) i...
lockup = open(lockfile,'w') os.chdir(download_dir) for filename in os.listdir('.') : if not os.path.islink(filename) and not os.path.isdir(filename): try: episode_info = getfileinfo(filename) try: moveshit = do_file_move(episode_info[0], episode_info[1], episode_info[2], episode_info[3], episode_info[4], episode_info[5...
lockup = open(lockfile,'w') os.chdir(download_dir) for filename in os.listdir('.') : if not os.path.islink(filename) and not os.path.isdir(filename): try: episode_info = getfileinfo(filename) try: moveshit = do_file_move(episode_info[0], episode_info[1], episode_info[2], episode_info[3], episode_info[4], episode_info[5...
def do_file_move(showid, showname, snum, enum, epname, quality, fileext, origfilename): season_dir = 'Season ' + snum episode_filename = '[' + snum + 'x' + enum + ']' + ' ' + epname + ' [' + quality + ']' + fileext newpath = os.path.join(tv_dir, showname, season_dir, episode_filename) sdir = os.path.split(newpath) i...
return x
filepath = x return filepath
def find_origfilename(fullnukepath): for x in os.listdir(download_dir): linkpath = os.path.join(download_dir, x) if os.path.islink(linkpath): if fullnukepath == os.readlink(linkpath): return x
errormessage = 'ACTION=MOVE STATUS=ERROR FILE=' + filename + ' ERROR=' + inst
errormessage = 'ACTION=MOVE STATUS=ERROR FILE=' + filename + ' ERROR=' + str(inst)
def do_file_move(showid, showname, snum, enum, epname, quality, fileext, origfilename): season_dir = 'Season ' + snum episode_filename = '[' + snum + 'x' + enum + ']' + ' ' + epname + ' [' + quality + ']' + fileext newpath = os.path.join(tv_dir, showname, season_dir, episode_filename) sdir = os.path.split(newpath) i...
errormessage = 'ACTION=MOVE STATUS=ERROR FILE=' + os.path.join(download_dir, filename) + ' ERROR=' + inst
errormessage = 'ACTION=MOVE STATUS=ERROR FILE=' + os.path.join(download_dir, filename) + ' ERROR=' + str(inst)
def do_file_move(showid, showname, snum, enum, epname, quality, fileext, origfilename): season_dir = 'Season ' + snum episode_filename = '[' + snum + 'x' + enum + ']' + ' ' + epname + ' [' + quality + ']' + fileext newpath = os.path.join(tv_dir, showname, season_dir, episode_filename) sdir = os.path.split(newpath) i...
errormessage = 'ACTION=IDENTIFY STATUS=ERROR FILE=' + filename + ' ERROR=' + inst
errormessage = 'ACTION=IDENTIFY STATUS=ERROR FILE=' + filename + ' ERROR=' + str(inst)
def do_file_move(showid, showname, snum, enum, epname, quality, fileext, origfilename): season_dir = 'Season ' + snum episode_filename = '[' + snum + 'x' + enum + ']' + ' ' + epname + ' [' + quality + ']' + fileext newpath = os.path.join(tv_dir, showname, season_dir, episode_filename) sdir = os.path.split(newpath) i...
errormessage = 'ACTION=IDENTIFY STATUS=ERROR FILE=' + os.path.join(download_dir, filename) + ' ERROR=' + inst
errormessage = 'ACTION=IDENTIFY STATUS=ERROR FILE=' + os.path.join(download_dir, filename) + ' ERROR=' + str(inst)
def do_file_move(showid, showname, snum, enum, epname, quality, fileext, origfilename): season_dir = 'Season ' + snum episode_filename = '[' + snum + 'x' + enum + ']' + ' ' + epname + ' [' + quality + ']' + fileext newpath = os.path.join(tv_dir, showname, season_dir, episode_filename) sdir = os.path.split(newpath) i...
self.find_relink()
if self.nuke_reason == 'BETTERAVAIL': os.symlink(self.nuke_path_new, self.episode_to_be_nuked) else: self.find_relink()
def do_nuke(self): shutil.move(self.episode_to_be_nuked, self.nuke_path_new) self.find_relink()
if o in ("-t", "--tv_dir"):
elif o in ("-t", "--tv_dir"):
def usage(): print "sofabuddy.py [options]" print 'Example' print '\tsofabuddy.py -d "/media/downloads" -h "192.168.1.1"' print "Options" print "\t-?, --help\t\t\tWill bring up this message" print "\t-d, --download_dir\t\tOverride the default download directory" print "\t-n, --nuke_dir\t\t\tOverride the default nuke di...
if o in ("-l", "--log_file"):
elif o in ("-l", "--log_file"):
def usage(): print "sofabuddy.py [options]" print 'Example' print '\tsofabuddy.py -d "/media/downloads" -h "192.168.1.1"' print "Options" print "\t-?, --help\t\t\tWill bring up this message" print "\t-d, --download_dir\t\tOverride the default download directory" print "\t-n, --nuke_dir\t\t\tOverride the default nuke di...
ugroup = "{ \"%s\"" % (name,)
ugroup = "{ \"%s\", +1" % (name,)
def PrintGroup(name, codes): """Print the data structures for the group of codes. Return a UGroup literal for the group.""" # See unicode_groups.h for a description of the data structure. # Split codes into 16-bit ranges and 32-bit ranges. range16 = MakeRanges([c for c in codes if c < 65536]) range32 = MakeRanges([c ...
n.attr['heigth']='1.5'
n.attr['height']='1.5'
def makeGraph(self,filename,graph=None): if (graph is None): graph=self.graph outdot=filename+'.dot' self.log.info('Creating graph Image: %s , dotfile: %s '%(filename,outdot)) # WTF... INCHES ! self.log.debug('making graph') G=nx.to_agraph(graph) self.log.debug('%d nodes'%(len( G.nodes()) ) ) G.graph_attr['label']='G...
str = lambda x: (('%%%d.%df' % (self.row_label_width, self.row_label_precision)) % x)
str = lambda x: (('%%%ds' % (self.row_label_width)) % x)
def format_label(self): str = lambda x: (('%%%d.%df' % (self.row_label_width, self.row_label_precision)) % x) return " ".join(map(str, self.labels))
self.data.append( (label, list(value) ) )
if isinstance(value, list): self.data.append( (label, value ) ) else: self.data.append( (label, [value] ) )
def __setitem__(self, name, value): self.labels.append(name) label = self.format_label() self.labels = []
row_header = " ".join(map(rowstr, self.rows)) row_header += " ".join(map(colstr, self.cols)) lines.append(row_header)
table_header = "" if isinstance(self.rows, str): table_header += "%%%ds" % self.row_label_width % self.rows else: table_header += " ".join(map(rowstr, self.rows)) table_header += " ".join(map(colstr, self.cols)) lines.append(table_header)
def __str__(self): rowstr = lambda x: '%%%ds' % self.row_label_width % x colstr = lambda x: '%%%ds' % self.width % x
if matchobj.group(1) != "":
if module != "":
def process_set_commands(matchobj): spaces = matchobj.group(1) module = matchobj.group(2) commands = matchobj.group(3) command_lines = re.split('\n', commands) result = [] for line in command_lines: temp = re.sub(r'#.*', "", line) result.append(re.sub(r'^\s*()(\w+)\s+(.*)($|#.*)', process_set_command, temp)) if match...
set_commands += spaces.join(result)
set_commands += (spaces+"\n").join(result)
def process_set_commands(matchobj): spaces = matchobj.group(1) module = matchobj.group(2) commands = matchobj.group(3) command_lines = re.split('\n', commands) result = [] for line in command_lines: temp = re.sub(r'#.*', "", line) result.append(re.sub(r'^\s*()(\w+)\s+(.*)($|#.*)', process_set_command, temp)) if match...
molecule += 'PsiMod.set_namespace("%s")' % (name)
molecule += 'PsiMod.IO.set_default_namespace("%s")' % (name)
def process_molecule_command(matchobj): spaces = matchobj.group(1) name = matchobj.group(2) geometry = matchobj.group(3) reorient = "True" com = "True" molecule = spaces if name != "": molecule += '%s = ' % (name) molecule += 'geometry("""%s"""' % (geometry) molecule += ',%s' % (reorient) molecule += ',%s' % (com) if ...
search_result = self.nmr_regex.search(castep_file)
search_results = self.nmr_regex.findall(castep_file)
def parse(self, castep_file): search_result = self.nmr_regex.search(castep_file)
if search_result is None:
if search_results is []:
def parse(self, castep_file): search_result = self.nmr_regex.search(castep_file)
heading_groups = self.heading_group_regex.findall(search_result.group(1)) headings = self.heading_regex.findall(search_result.group(2))
search_result = search_results[len(search_results) - 1]
def parse(self, castep_file): search_result = self.nmr_regex.search(castep_file)
entry_rows = self.entry_row_regex.findall(search_result.group(3))
heading_groups = self.heading_group_regex.findall(search_result[0]) headings = self.heading_regex.findall(search_result[1]) entry_rows = self.entry_row_regex.findall(search_result[2])
def parse(self, castep_file): search_result = self.nmr_regex.search(castep_file)
self.groups = [re.sub(r"\(.*?\)", "", heading.lower()) for heading in headings]
self.groups = [heading.lower() for heading in headings]
def parse(self, castep_file): search_result = self.nmr_regex.search(castep_file)
if search_results is []: raise NoNMRResult()
if search_results is [] or len(search_results) == 0: raise self.NoNMRResult()
def parse(self, castep_file): search_results = self.nmr_regex.findall(castep_file)
def csv(self, species):
def csv(self, species, number=None):
def csv(self, species): s = "#" + ", ".join(self.groups) + "\n"
if species is None or species == ion['species']:
if (species is None or species == ion['species']) and (number is None or number==ion['ion']):
def csv(self, species): s = "#" + ", ".join(self.groups) + "\n"
if 'POSITIONS_ABS' in self.blocks: self.ions_type = 'POSITIONS_ABS' elif 'POSITIONS_FRAC' in self.blocks: self.ions_type = 'POSITIONS_FRAC'
self.ions_type = 'POSITIONS_FRAC' if 'POSITIONS_ABS' in self.blocks: self.ions_type = 'POSITIONS_ABS' elif 'POSITIONS_FRAC' in self.blocks: self.ions_type = 'POSITIONS_FRAC'
def parse_cell(self, cell): import re block_re = re.compile(r"%block (.*?)\n(.*?\n{0,})%endblock (.*?)\n", re.I | re.S | re.M)
j_site = self.otherdict['jcoupling_site'].split()
if 'jcoupling_site' not in self.otherdict: j_site = raw_input("Specify the j-coupling site: ").split() self.other.append("jcoupling_site: " + " ".join(j_site)) else: j_site = self.otherdict['jcoupling_site'].split()
def hack_perturb_origin(self): """ Hack to move the perturbing NMR nucleus onto the origin """ j_site = self.otherdict['jcoupling_site'].split() j_site_ion = self.ion_index[j_site[0]][int(j_site[1])-1] ions_prime = [] for species, pos in self.ions: new_ion = (species, (pos[0]-j_site_ion[1][0], pos[1]-j_site_ion[1][1...
self.blocks[name] = lines
self.blocks[name.upper()] = lines
def parse_cell(self, cell): import re block_re = re.compile(r"%block (.*?)\n(.*?\n{0,})%endblock (.*?)\n", re.I | re.S | re.M)
self.ions_type = 'POSITIONS_ABS'
if 'POSITIONS_ABS' in self.blocks: self.ions_type = 'POSITIONS_ABS' elif 'POSITIONS_FRAC' in self.blocks: self.ions_type = 'POSITIONS_FRAC'
def parse_cell(self, cell): import re block_re = re.compile(r"%block (.*?)\n(.*?\n{0,})%endblock (.*?)\n", re.I | re.S | re.M)
if options.autogen: config.alwaysautogen = True if options.clean: config.makeclean = True
def run(self, config, options, args, help=None): config.buildscript = 'autobuild'
gtk.window_set_default_icon_list( theme.load_icon('applications-development', 16, ()), theme.load_icon('applications-development', 24, ()), theme.load_icon('applications-development', 32, ()), theme.load_icon('applications-development', 48, ()), theme.load_icon('applications-development', 64, ()), theme.load_icon('appl...
if theme.has_icon('applications-development'): gtk.window_set_default_icon_list( theme.load_icon('applications-development', 16, ()), theme.load_icon('applications-development', 24, ()), theme.load_icon('applications-development', 32, ()), theme.load_icon('applications-development', 48, ()), theme.load_icon('applicatio...
def __init__(self, config, module_list=None): self.orig_modulelist = module_list buildscript.BuildScript.__init__(self, config) self.config = config gtk.Window.__init__(self) self.set_resizable(False) theme = gtk.icon_theme_get_default() gtk.window_set_default_icon_list( theme.load_icon('applications-development', 16, ...
path_elements.append(os.path.basename(self.module))
path_elements.append(self.get_module_basename())
def srcdir(self): path_elements = [self.checkoutroot] if self.checkoutdir: path_elements.append(self.checkoutdir) else: path_elements.append(os.path.basename(self.module)) if self.subdir: path_elements.append(self.subdir) return os.path.join(*path_elements)
self.switch_branch_if_necessary(buildscript) self.pull_current_branch(buildscript)
def _update(self, buildscript, copydir=None, update_mirror=True): cwd = self.get_checkoutdir() git_extra_args = {'cwd': cwd, 'extra_env': get_git_extra_env()}
def __init__(self, config, name, href, trunk_template='%(module)s', branches_template=''):
def __init__(self, config, name, href, trunk_template='%(module)s', branches_template='%(module)s/%(branch)s'):
def __init__(self, config, name, href, trunk_template='%(module)s', branches_template=''): Repository.__init__(self, config, name) # allow user to adjust location of branch. self.href = config.repos.get(name, href) self.trunk_template = trunk_template self.branches_template = branches_template
branch_xml_attrs = ['module', 'checkoutdir', 'revision', 'tag'] def branch(self, name, module=None, checkoutdir=None, revision=None, tag=None): module_href = None
branch_xml_attrs = ['module', 'checkoutdir', 'revision', 'tag', 'user', 'revspec', 'branch'] def branch(self, name, module=None, checkoutdir=None, revision=None, tag=None, user=None, revspec=None, branch=None, module_href=None):
def __init__(self, config, name, href, trunk_template='%(module)s', branches_template=''): Repository.__init__(self, config, name) # allow user to adjust location of branch. self.href = config.repos.get(name, href) self.trunk_template = trunk_template self.branches_template = branches_template
if revision and not revision.isdigit():
if revision or branch:
def branch(self, name, module=None, checkoutdir=None, revision=None, tag=None): module_href = None if name in self.config.branches: module_href = self.config.branches[name] if not module_href: raise FatalError(_('branch for %s has wrong override, check your .jhbuildrc') % name)
'branch': revision, 'tag': tag
'branch': branch, 'tag' : tag, 'user': user,
def branch(self, name, module=None, checkoutdir=None, revision=None, tag=None): module_href = None if name in self.config.branches: module_href = self.config.branches[name] if not module_href: raise FatalError(_('branch for %s has wrong override, check your .jhbuildrc') % name)
return BzrBranch(self, module_href, checkoutdir, tag)
return BzrBranch(self, module_href, checkoutdir, tag, revspec)
def branch(self, name, module=None, checkoutdir=None, revision=None, tag=None): module_href = None if name in self.config.branches: module_href = self.config.branches[name] if not module_href: raise FatalError(_('branch for %s has wrong override, check your .jhbuildrc') % name)
def __init__(self, repository, module_href, checkoutdir, tag):
def __init__(self, repository, module_href, checkoutdir, tag, revspec):
def __init__(self, repository, module_href, checkoutdir, tag): Branch.__init__(self, repository, module_href, checkoutdir) self.tag = tag
self.tag = tag
self._revspec = None self.revspec = (tag, revspec) def get_revspec(self): return self._revspec def set_revspec(self, (tag, revspec)): if revspec: self._revspec = ['-r%s' % revspec] elif tag: logging.info('tag ' + _('attribute is deprecated. Use revspec instead.')) self._revspec = ['-rtag:%s' % tag] elif self.config.s...
def __init__(self, repository, module_href, checkoutdir, tag): Branch.__init__(self, repository, module_href, checkoutdir) self.tag = tag
if self.checkoutdir: return os.path.join(self.checkoutroot, self.checkoutdir) else: return os.path.join(self.checkoutroot, os.path.basename(self.module))
return Branch.get_checkoutdir(self)
def srcdir(self): if self.checkoutdir: return os.path.join(self.checkoutroot, self.checkoutdir) else: return os.path.join(self.checkoutroot, os.path.basename(self.module))
return None
try: return get_output(['bzr', 'nick', self.srcdir]) except: return None
def branchname(self): return None
def _checkout(self, buildscript): cmd = ['bzr', 'branch', self.module] if self.checkoutdir: cmd.append(self.checkoutdir) if self.tag: cmd.append('-rtag:%s' % self.tag) if self.config.sticky_date: raise FatalError(_('date based checkout not yet supported\n')) buildscript.execute(cmd, 'bzr', cwd=self.checkoutroot) de...
def create_mirror(self, buildscript): if not self.config.dvcs_mirror_dir: return if self.config.nonetwork: return if not os.path.exists(os.path.join(self.config.dvcs_mirror_dir, '.bzr')): cmd = ['bzr', 'init-repo', '--no-trees', self.config.dvcs_mirror_dir] buildscript.execute(cmd) local_mirror = os.path.join(self.co...
def _checkout(self, buildscript): cmd = ['bzr', 'branch', self.module] if self.checkoutdir: cmd.append(self.checkoutdir)
output = get_output(['bzr', 'revno'], cwd = self.srcdir) return output.strip()
else: cmd = ['bzr', 'revision-info', '--tree', '-d', self.srcdir] return get_output(cmd).strip()
def tree_id(self): if not os.path.exists(self.srcdir): return None output = get_output(['bzr', 'revno'], cwd = self.srcdir) return output.strip()
def _execute_git_predicate(self, predicate):
def execute_git_predicate(self, predicate):
def _execute_git_predicate(self, predicate): """A git command wrapper for the cases, where only the boolean outcome is of interest. """ try: get_output(predicate, cwd=self.get_checkoutdir(), extra_env=get_git_extra_env()) except CommandError: return False return True
def _is_local_branch(self, branch): return self._execute_git_predicate( ['git', 'show-ref', '--quiet',
def is_local_branch(self, branch): return self.execute_git_predicate( ['git', 'show-ref', '--quiet',
def _is_local_branch(self, branch): return self._execute_git_predicate( ['git', 'show-ref', '--quiet', '--verify', 'refs/heads/' + branch])
def _is_inside_work_tree(self): return self._execute_git_predicate(
def is_inside_work_tree(self): return self.execute_git_predicate(
def _is_inside_work_tree(self): return self._execute_git_predicate( ['git', 'rev-parse', '--is-inside-work-tree'])
def _is_tracking_a_remote_branch(self, local_branch):
def is_tracking_a_remote_branch(self, local_branch):
def _is_tracking_a_remote_branch(self, local_branch): if not local_branch: return False current_branch_remote_config = 'branch.%s.remote' % local_branch return self._execute_git_predicate( ['git', 'config', '--get', current_branch_remote_config])
return self._execute_git_predicate(
return self.execute_git_predicate(
def _is_tracking_a_remote_branch(self, local_branch): if not local_branch: return False current_branch_remote_config = 'branch.%s.remote' % local_branch return self._execute_git_predicate( ['git', 'config', '--get', current_branch_remote_config])
if not self._check_version_git('1.5.6'):
if not self.check_version_git('1.5.6'):
def is_dirty(self, ignore_submodules=True): submodule_options = [] if ignore_submodules: if not self._check_version_git('1.5.6'): raise CommandError(_('Need at least git-1.5.6 from June/08 ' 'to operate')) submodule_options = ['--ignore-submodules'] return not self._execute_git_predicate( ['git', 'diff', '--exit-code',...
return not self._execute_git_predicate(
return not self.execute_git_predicate(
def is_dirty(self, ignore_submodules=True): submodule_options = [] if ignore_submodules: if not self._check_version_git('1.5.6'): raise CommandError(_('Need at least git-1.5.6 from June/08 ' 'to operate')) submodule_options = ['--ignore-submodules'] return not self._execute_git_predicate( ['git', 'diff', '--exit-code',...
def _check_version_git(self, version_spec):
def check_version_git(self, version_spec):
def _check_version_git(self, version_spec): return check_version(['git', '--version'], r'git version ([\d.]+)', version_spec, extra_env=get_git_extra_env())
def _get_current_branch(self):
def get_current_branch(self):
def _get_current_branch(self): """Returns either a branchname or None if head is detached""" if not self._is_inside_work_tree(): raise CommandError(_('Unexpected: Checkoutdir is not a git ' 'repository:' + self.get_checkoutdir())) try: return os.path.basename( get_output(['git', 'symbolic-ref', '-q', 'HEAD'], cwd=self....
if not self._is_inside_work_tree():
if not self.is_inside_work_tree():
def _get_current_branch(self): """Returns either a branchname or None if head is detached""" if not self._is_inside_work_tree(): raise CommandError(_('Unexpected: Checkoutdir is not a git ' 'repository:' + self.get_checkoutdir())) try: return os.path.basename( get_output(['git', 'symbolic-ref', '-q', 'HEAD'], cwd=self....
def _find_remote_branch_online_if_necessary(self, buildscript,
def find_remote_branch_online_if_necessary(self, buildscript,
def _find_remote_branch_online_if_necessary(self, buildscript, remote_name, branch_name): """Try to find the given branch first, locally, then remotely, and state the availability in the return value.""" wanted_ref = remote_name + '/' + branch_name if self._execute_git_predicate( ['git', 'show-ref', wanted_ref]): retur...
if self._execute_git_predicate( ['git', 'show-ref', wanted_ref]):
if self.execute_git_predicate( ['git', 'show-ref', wanted_ref]):
def _find_remote_branch_online_if_necessary(self, buildscript, remote_name, branch_name): """Try to find the given branch first, locally, then remotely, and state the availability in the return value.""" wanted_ref = remote_name + '/' + branch_name if self._execute_git_predicate( ['git', 'show-ref', wanted_ref]): retur...
return self._execute_git_predicate( ['git', 'show-ref', wanted_ref]) def _get_branch_switch_destination(self): current_branch = self._get_current_branch()
return self.execute_git_predicate( ['git', 'show-ref', wanted_ref]) def get_branch_switch_destination(self): current_branch = self.get_current_branch()
def _find_remote_branch_online_if_necessary(self, buildscript, remote_name, branch_name): """Try to find the given branch first, locally, then remotely, and state the availability in the return value.""" wanted_ref = remote_name + '/' + branch_name if self._execute_git_predicate( ['git', 'show-ref', wanted_ref]): retur...
and self._is_tracking_a_remote_branch(current_branch):
and self.is_tracking_a_remote_branch(current_branch):
def _get_branch_switch_destination(self): current_branch = self._get_current_branch() wanted_branch = self.branch or 'master'
def _switch_branch_if_necessary(self, buildscript):
def switch_branch_if_necessary(self, buildscript):
def _switch_branch_if_necessary(self, buildscript): """ The switch depends on the requested tag, the requested branch, and the state and type of the current branch.
wanted_branch = self._get_branch_switch_destination()
wanted_branch = self.get_branch_switch_destination()
def _switch_branch_if_necessary(self, buildscript): """ The switch depends on the requested tag, the requested branch, and the state and type of the current branch.
if self._is_local_branch(wanted_branch):
if self.is_local_branch(wanted_branch):
def _switch_branch_if_necessary(self, buildscript): """ The switch depends on the requested tag, the requested branch, and the state and type of the current branch.
if not self._find_remote_branch_online_if_necessary(
if not self.find_remote_branch_online_if_necessary(
def _switch_branch_if_necessary(self, buildscript): """ The switch depends on the requested tag, the requested branch, and the state and type of the current branch.
def _pull_current_branch(self, buildscript):
def pull_current_branch(self, buildscript):
def _pull_current_branch(self, buildscript): """Pull the current branch if it is tracking a remote branch.""" if not self._is_tracking_a_remote_branch(self._get_current_branch()): return
if not self._is_tracking_a_remote_branch(self._get_current_branch()):
if not self.is_tracking_a_remote_branch(self.get_current_branch()):
def _pull_current_branch(self, buildscript): """Pull the current branch if it is tracking a remote branch.""" if not self._is_tracking_a_remote_branch(self._get_current_branch()): return
if self._check_version_git('1.5.5'):
if self.check_version_git('1.5.5'):
def _pull_current_branch(self, buildscript): """Pull the current branch if it is tracking a remote branch.""" if not self._is_tracking_a_remote_branch(self._get_current_branch()): return
def _rewind_to_sticky_date(self, buildscript):
def rewind_to_sticky_date(self, buildscript):
def _rewind_to_sticky_date(self, buildscript): if self.config.quiet_mode: quiet = ['-q'] else: quiet = [] commit = self._get_commit_from_date() branch = 'jhbuild-date-branch' branch_cmd = ['git', 'checkout'] + quiet + [branch] git_extra_args = {'cwd': self.get_checkoutdir(), 'extra_env': get_git_extra_env()} try: build...
self._switch_branch_if_necessary(buildscript) self._pull_current_branch(buildscript)
self.switch_branch_if_necessary(buildscript) self.pull_current_branch(buildscript)
def _update(self, buildscript, copydir=None, update_mirror=True): cwd = self.get_checkoutdir() git_extra_args = {'cwd': cwd, 'extra_env': get_git_extra_env()}
self._rewind_to_sticky_date(buildscript)
self.rewind_to_sticky_date(buildscript)
def _update(self, buildscript, copydir=None, update_mirror=True): cwd = self.get_checkoutdir() git_extra_args = {'cwd': cwd, 'extra_env': get_git_extra_env()}
if config.modulesets_dir and config.nonetwork or config.use_local_modulesets:
if os.path.isabs(uri): pass elif config.modulesets_dir and config.nonetwork or config.use_local_modulesets:
def load(config, uri=None): if uri is not None: modulesets = [ uri ] elif type(config.moduleset) in (list, tuple): modulesets = config.moduleset else: modulesets = [ config.moduleset ] ms = ModuleSet(config = config) for uri in modulesets: if config.modulesets_dir and config.nonetwork or config.use_local_modulesets: if...
module_name = module_name.lower()
module_name_lower = module_name.lower()
def get_module(self, module_name, ignore_case = False): if self.modules.has_key(module_name) or not ignore_case: return self.modules[module_name] module_name = module_name.lower() for module in self.modules.keys(): if module.lower() == module_name: if self.config is None or not self.config.quiet_mode: logging.info(_('f...
if module.lower() == module_name:
if module.lower() == module_name_lower:
def get_module(self, module_name, ignore_case = False): if self.modules.has_key(module_name) or not ignore_case: return self.modules[module_name] module_name = module_name.lower() for module in self.modules.keys(): if module.lower() == module_name: if self.config is None or not self.config.quiet_mode: logging.info(_('f...
logging.info(_('fixed case of module \'%(orig)s\' to \'%(new)s\'') % { 'orig': module_name, 'new': module})
logging.info(_('fixed case of module \'%s\' to \'%s\'') % (module_name, module))
def get_module(self, module_name, ignore_case = False): if self.modules.has_key(module_name) or not ignore_case: return self.modules[module_name] module_name = module_name.lower() for module in self.modules.keys(): if module.lower() == module_name: if self.config is None or not self.config.quiet_mode: logging.info(_('f...
return (e, error_phases)
return (str(e), error_phases)
def run_phase(self, buildscript, phase): """run a particular part of the build for this package.
elif not urlparse.urlparse(uri).scheme:
elif not urlparse.urlparse(uri)[0]:
def load(config, uri=None): if uri is not None: modulesets = [ uri ] elif type(config.moduleset) in (list, tuple): modulesets = config.moduleset else: modulesets = [ config.moduleset ] ms = ModuleSet(config = config) for uri in modulesets: if config.modulesets_dir and config.nonetwork or config.use_local_modulesets: if...
module = urlparse.urljoin(self.href, module)
if self.href.endswith('/'): base_href = self.href else: base_href = self.href + '/' module = base_href + module
def branch(self, name, module = None, subdir="", checkoutdir = None, revision = None, tag = None): if module is None: module = name
mirror_module = os.path.join(self.config.dvcs_mirror_dir, module)
mirror_module = get_git_mirror_directory( self.config.dvcs_mirror_dir, checkoutdir, module)
def branch(self, name, module = None, subdir="", checkoutdir = None, revision = None, tag = None): if module is None: module = name
mirror_dir = os.path.join(self.config.dvcs_mirror_dir, self.get_module_basename() + '.git')
mirror_dir = get_git_mirror_directory(self.config.dvcs_mirror_dir, self.checkoutdir, self.unmirrored_module)
def update_dvcs_mirror(self, buildscript): if not self.config.dvcs_mirror_dir: return if self.config.nonetwork: return
['git', 'clone', '--mirror', self.unmirrored_module], cwd=self.config.dvcs_mirror_dir, extra_env=get_git_extra_env())
['git', 'clone', '--mirror', self.unmirrored_module, mirror_dir], extra_env=get_git_extra_env())
def update_dvcs_mirror(self, buildscript): if not self.config.dvcs_mirror_dir: return if self.config.nonetwork: return
rc = jhbuild.commands.run(command, config, args[1:])
rc = jhbuild.commands.run(command, config, args[1:], help=None)
def run(self, config, options, args, help=None): if options.setup: return self.setup(config)
srcdir = self.get_srcdir(buildscript) if not os.path.exists(srcdir): return True if not os.path.exists(os.path.join(srcdir, self.makefile)):
builddir = self.get_builddir(buildscript) if not os.path.exists(builddir): return True if not os.path.exists(os.path.join(builddir, self.makefile)):
def skip_clean(self, buildscript, last_phase): srcdir = self.get_srcdir(buildscript) if not os.path.exists(srcdir): return True if not os.path.exists(os.path.join(srcdir, self.makefile)): return True return False
return output.strip()
id_suffix = '' if self.is_dirty(): id_suffix = self.dirty_branch_suffix return output.strip() + id_suffix
def tree_id(self): if not os.path.exists(self.get_checkoutdir()): return None try: output = get_output(['git', 'rev-parse', 'HEAD'], cwd = self.get_checkoutdir(), get_stderr=False, extra_env=get_git_extra_env()) except CommandError: return None except GitUnknownBranchNameError: return None return output.strip()
os.path.basename(self.module) + '.git')
self.get_module_basename() + '.git')
def update_dvcs_mirror(self, buildscript): if not self.config.dvcs_mirror_dir: return if self.config.nonetwork: return
buildscript.execute(['autoreconf', '-i'], cwd=builddir,
buildscript.execute(['autoreconf', '-i'], cwd=srcdir,
def do_configure(self, buildscript): builddir = self.get_builddir(buildscript) if buildscript.config.buildroot and not os.path.exists(builddir): os.makedirs(builddir) buildscript.set_action(_('Configuring'), self)
lastlog = ''
def body (self, request): data = ''
cmd = '%s %s clean' % (os.environ.get('MAKE', 'make'), makeargs)
builddir = self.get_builddir(buildscript) cmd = '%s %s clean' % (os.environ.get('MAKE', 'make'), self.get_makeargs())
def do_clean(self, buildscript): buildscript.set_action(_('Cleaning'), self) cmd = '%s %s clean' % (os.environ.get('MAKE', 'make'), makeargs) buildscript.execute(cmd, cwd = builddir, extra_env = self.extra_env)
module_list = [module_set.get_module(modname, ignore_case = True) for modname in args]
try: module_list = [module_set.get_module(modname, ignore_case = True) \ for modname in args] except KeyError: raise FatalError(_('unknown module %s') % modname)
def run(self, config, options, args, help=None): config.set_from_cmdline_options(options)
attrs['branch'] = self.branch
attrs['revision'] = self.branch if self.checkoutdir: attrs['checkoutdir'] = self.checkoutdir if self.subdir: attrs['subdir'] = self.subdir
def to_sxml(self): attrs = {} if self.branch: attrs['branch'] = self.branch return [sxml.branch(repo=self.repository.name, module=self.module, tag=self.tree_id(), **attrs)]
if len(output) > columns: output = output[:columns] else: output += ' ' * (columns-len(output)) sys.stdout.write(output + '\r')
text_width = len(output) - (len(t_bold) + len(t_reset)) if text_width > columns: output = output[:columns+len(t_bold)] + t_reset else: output += ' ' * (columns-text_width) sys.stdout.write('\r'+output)
def display_status_line(self, progress, module_num, message): if self.is_end_of_build: # hardcode progress to 100% at the end of the build progress = 1
if module.__class__ == testmodule.TestModule:
if module.__class__ == TestModule:
def load_tests (config, uri=None): ms = load (config, uri) ms_tests = ModuleSet(config = config) for app, module in ms.modules.iteritems(): if module.__class__ == testmodule.TestModule: ms_tests.modules[app] = module return ms_tests
['wget', '--continue', self.module, '-O', localfile])
['wget', '--continue', self.module, '-O', localfile], extra_env={ 'LD_LIBRARY_PATH': os.environ.get('UNMANGLED_LD_LIBRARY_PATH'), 'PATH': os.environ.get('UNMANGLED_PATH')})
def _download_and_unpack(self, buildscript): localfile = self._local_tarball if not os.path.exists(self.config.tarballdir): try: os.makedirs(self.config.tarballdir) except OSError: raise FatalError( _('tarball dir (%s) can not be created') % self.config.tarballdir) if not os.access(self.config.tarballdir, os.R_OK|os.W_...
['curl', '--continue-at', '-', '-L', self.module, '-o', localfile])
['curl', '--continue-at', '-', '-L', self.module, '-o', localfile], extra_env={ 'LD_LIBRARY_PATH': os.environ.get('UNMANGLED_LD_LIBRARY_PATH'), 'PATH': os.environ.get('UNMANGLED_PATH')})
def _download_and_unpack(self, buildscript): localfile = self._local_tarball if not os.path.exists(self.config.tarballdir): try: os.makedirs(self.config.tarballdir) except OSError: raise FatalError( _('tarball dir (%s) can not be created') % self.config.tarballdir) if not os.access(self.config.tarballdir, os.R_OK|os.W_...
if '/' not in uri and not os.path.isfile(uri): if config.modulesets_dir and config.nonetwork or config.use_local_modulesets:
if config.modulesets_dir and config.nonetwork or config.use_local_modulesets: if os.path.isfile(os.path.join(config.modulesets_dir, uri + '.modules')):
def load(config, uri=None): if uri is not None: modulesets = [ uri ] elif type(config.moduleset) in (list, tuple): modulesets = config.moduleset else: modulesets = [ config.moduleset ] ms = ModuleSet(config = config) for uri in modulesets: if '/' not in uri and not os.path.isfile(uri): if config.modulesets_dir and conf...
else: uri = 'http://git.gnome.org/browse/jhbuild/plain/modulesets/%s.modules' % uri
elif os.path.isfile(os.path.join(config.modulesets_dir, uri)): uri = os.path.join(config.modulesets_dir, uri) elif not urlparse.urlparse(uri).scheme: uri = 'http://git.gnome.org/browse/jhbuild/plain/modulesets' \ '/%s.modules' % uri
def load(config, uri=None): if uri is not None: modulesets = [ uri ] elif type(config.moduleset) in (list, tuple): modulesets = config.moduleset else: modulesets = [ config.moduleset ] ms = ModuleSet(config = config) for uri in modulesets: if '/' not in uri and not os.path.isfile(uri): if config.modulesets_dir and conf...
if get_output(['git', 'diff'], **git_extra_args):
git_diff_output = get_output(['git', 'diff'] + git_diff_submodule, **git_extra_args) git_diff_output = '\n'.join([x for x in git_diff_output.splitlines() \ if not x.startswith('Submodule ')]) if git_diff_output:
def _update(self, buildscript, copydir=None, update_mirror=True): cwd = self.get_checkoutdir() git_extra_args = {'cwd': cwd, 'extra_env': get_git_extra_env()}
config.build_targets = ['clean'] config.nonetwork = False
def run(self, config, options, args, help=None): if options.honour_config is False: config.makeclean = True module_set = jhbuild.moduleset.load(config) try: module_list = [module_set.get_module(modname, ignore_case = True) for modname in args] except KeyError, e: raise FatalError(_("A module called '%s' could not be fo...
return build.build()
return build.build(phases=['clean'])
def run(self, config, options, args, help=None): if options.honour_config is False: config.makeclean = True module_set = jhbuild.moduleset.load(config) try: module_list = [module_set.get_module(modname, ignore_case = True) for modname in args] except KeyError, e: raise FatalError(_("A module called '%s' could not be fo...