rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
return "%s (%s)" % (self.name, self.type) | return u"%s (%s)" % (self.name, self.type) | def __unicode__(self): return "%s (%s)" % (self.name, self.type) |
return "CPRM: [name:%s, type:%s]" % (self.name, self.type) | return u"CPRM: [name:%s, type:%s]" % (self.name, self.type) | def __unicode__(self): return "CPRM: [name:%s, type:%s]" % (self.name, self.type) |
return "Name: {0} - Type: {1}".format(self.name, self.type) | return u"Name: {0} - Type: {1}".format(self.name, self.type) | def __unicode__(self): return "Name: {0} - Type: {1}".format(self.name, self.type) |
return "{0} -> [{1}: {2}]".format(self.round_configuration, self.parameter, self.parameter_value) | return u"{0} -> [{1}: {2}]".format(self.round_configuration, self.parameter, self.parameter_value) | def __unicode__(self): return "{0} -> [{1}: {2}]".format(self.round_configuration, self.parameter, self.parameter_value) |
return "%s.%d" % (self.experiment.event_channel_name, self.number) | return u"%s.%d" % (self.experiment.event_channel_name, self.number) | def channel(self): return "%s.%d" % (self.experiment.event_channel_name, self.number) |
return "Group | return u"Group | def __unicode__(self): return "Group #{0} in {1}".format(self.number, self.experiment) |
return "Round Data for {0} in {1}".format(self.group, self.round) | return u"Round Data for {0} in {1}".format(self.group, self.round) | def __unicode__(self): return "Round Data for {0} in {1}".format(self.group, self.round) |
return "Data value: [parameter {0}, value {1}], recorded at {2} for experiment {3}".format(self.parameter, self.parameter_value, self.time_recorded, self.experiment) | return u"Data value: [parameter {0}, value {1}], recorded at {2} for experiment {3}".format(self.parameter, self.parameter_value, self.time_recorded, self.experiment) | def __unicode__(self): return "Data value: [parameter {0}, value {1}], recorded at {2} for experiment {3}".format(self.parameter, self.parameter_value, self.time_recorded, self.experiment) |
return "Experiment {0} - participant {1} (created {2})".format(self.experiment, self.participant, self.date_created) | return u"Experiment {0} - participant {1} (created {2})".format(self.experiment, self.participant, self.date_created) | def __unicode__(self): return "Experiment {0} - participant {1} (created {2})".format(self.experiment, self.participant, self.date_created) |
return "{0}: {1}".format(participant_number, self.message) | return u"{0}: {1}".format(participant_number, self.message) | def __unicode__(self): """ return this participant's sequence number combined with the message """ participant_number = self.participant.get_participant_number(self.experiment) return "{0}: {1}".format(participant_number, self.message) |
return "{0}: {1} (in {2})".format(self.participant, self.participant_number, self.group) | return u"{0}: {1} (in {2})".format(self.participant, self.participant_number, self.group) | def __unicode__(self): return "{0}: {1} (in {2})".format(self.participant, self.participant_number, self.group) |
r = dictionaryfile.readline().strip() while r != '': yield(r) r = dictionaryfile.readline().strip() | while 1: r = dictionaryfile.readline() if len(r) == 0: break yield(r.strip()) | def dictionaryattack(dictionaryfile): r = dictionaryfile.readline().strip() while r != '': yield(r) r = dictionaryfile.readline().strip() dictionaryfile.close() |
self.log.append( "The file: %s is broken") % (file) | self.log.append( "The file: <b>%s</b> is broken" % file ) | def scan(self): """Scan the directory where the collection is""" # we have to add a trailing slash for scanning indexer = MusicIndexer( settings.AUDIO_DIR + "/") dbPath = settings.DATABASE_NAME if not os.access(dbPath, os.W_OK): raise OSError("No write access to database! \ Use: <b>sudo chmod 0775 %s</b>" % (dbPath)) i... |
self.log.append( "The file: %s is not accessible due to filerights") % (file) | self.log.append( "The file: <b>%s</b> is not accessible due to filerights" % file ) | def scan(self): """Scan the directory where the collection is""" # we have to add a trailing slash for scanning indexer = MusicIndexer( settings.AUDIO_DIR + "/") dbPath = settings.DATABASE_NAME if not os.access(dbPath, os.W_OK): raise OSError("No write access to database! \ Use: <b>sudo chmod 0775 %s</b>" % (dbPath)) i... |
return HttpResponseRedirect( reverse ("laudio.views.laudio_profile") ') | return HttpResponseRedirect( reverse ("laudio.views.laudio_profile") ) | def laudio_profile(request): """Edit a profile""" user = request.user if request.method == 'POST': userform = UserEditProfileForm(request.POST) profileform = UserProfileForm(request.POST) if userform.is_valid() and profileform.is_valid(): user.email = userform.cleaned_data['email'] if request.POST.get('password') !=... |
def login( user, password, client=('ark', '2.3'), service="lastfm" ): | def login( user, password, client=('tst', '1.0'), service="lastfm" ): | def login( user, password, client=('ark', '2.3'), service="lastfm" ): """Authencitate with AS (The Handshake) @param user: The username @param password: The password @param client: Client information (see http://www.audioscrobbler.net/development/protocol/ for more info) @type client: Tuple: (client-id, clien... |
data = {} data["api_key"] = "a1d1111ab0b08262e6d7484cc5dc949a" data["method"] = "album.getinfo" data["artist"] = unicode(song.artist) data["album"] = unicode(song.album) url_values = urllib.urlencode(data) url = "http://ws.audioscrobbler.com/2.0/" full_url = url + '?' + url_values | def cover_fetch(request, id): song = Song.objects.get(id=id) local = False # get collection path collSymlink = os.path.join( os.path.dirname(__file__), 'media/audio').replace('\\', '/' ) collPath = os.readlink(collSymlink) # get the dirname joined with the collection path and # look if theres a png or jpeg in it songPa... | |
except (URLError, HTTPError): | except (URLError, HTTPError, UnicodeEncodeError): | def cover_fetch(request, id): song = Song.objects.get(id=id) local = False # get collection path collSymlink = os.path.join( os.path.dirname(__file__), 'media/audio').replace('\\', '/' ) collPath = os.readlink(collSymlink) # get the dirname joined with the collection path and # look if theres a png or jpeg in it songPa... |
return HttpResponseRedirect( settings.URL_PREFIX + "login/" ) | return HttpResponseRedirect( reverse ("laudio.views.laudio_login" ) ) | def wrapper(*args, **kwargs): """get the first argument which is always the request object and check if the user is authenticated""" try: config = Settings.objects.get(pk=1) requireLogin = config.requireLogin except Settings.DoesNotExist: requireLogin = False """Sites marked with admin are required to log in regardless... |
gapless = False transcode = False | def __init__(self, view, request): """First we set the functions and files we have to include for the view we serve Keyword arguments: view -- can be: "library", "settings" or "playlist"; sets javascript according to those views """ self.view = view # check config vars try: config = Settings.objects.get(pk=1) audio_... | |
mediaPath = '%smedia/audio' % settings.URL_PREFIX | mediaPath = '%smedia/audio' % reverse ("laudio.views.laudio_index") | def fetch(self): """ Fetches the songcover from different services First it looks locally if images already exists in the folder. Only Images with "cover" or "folder" are taken. If no cover is being found it queries online services and if it doesnt find anything the standardcover is being returned. """ # FIXME: we got ... |
for para in deb822.Deb822.iter_paragraphs(file(filename)): | input = file(filename).read().decode('utf-8') for para in deb822.Deb822.iter_paragraphs(input, use_apt_pkg=False): | def main(dir): num = 0 doc = Document() events = doc.createElement('data') doc.appendChild(events) for filename in glob(os.path.join(dir, '*')): print >>sys.stderr, "Reading events from %s" % filename, for para in deb822.Deb822.iter_paragraphs(file(filename)): events.appendChild(create_event(doc, para)) sys.stderr.wr... |
dydt0 = model.residual(t0, y0, numpy.zeros(3, numpy.float64))[0] | dydt0 = - model.residual(t0, y0, numpy.zeros(3, numpy.float64))[0] | #def jacobian(self, t, y, dydt, cj): #pd = -cj * numpy.identity(y.shape[0], numpy.float64) #pd[0,0] += -self.k1 #pd[1,0] += self.k1 #pd[1,1] += -self.k2 #pd[2,1] += self.k2 #return pd |
utils.run_cmd("git config remote.origin.url=%s"%self.git_repo) | utils.run_cmd("git config remote.origin.url %s"%self.git_repo) | def pull(self): os.chdir(self.co_path) |
utils.run_cmd("git config remote.origin.url=%s"%self.git_repo) | utils.run_cmd("git config remote.origin.url %s"%self.git_repo) | def push(self): os.chdir(self.co_path) if (self.branch is not None): effective_branch = "remotes/origin/%s:%s" % (self.branch, self.branch) else: effective_branch = "" utils.run_cmd("git config remote.origin.url=%s"%self.git_repo) utils.run_cmd("git push origin %s"%effective_branch) |
print 'query unused %s'%args | def _query_unused(self, builder, args): targets = [] print 'query unused %s'%args if args: for thing in args: if thing == '_all': raise utils.Failure("It does not make sense to ask for" " 'muddle query unused _all'") targets.append(depend.Label.from_string(thing)) else: print 'Using default deployables:' targets = buil... | |
else: print 'Using default deployables:' | print 'Finding labels unused by:' else: print 'Finding labels unused by the default deployables:' | def _query_unused(self, builder, args): targets = [] print 'query unused %s'%args if args: for thing in args: if thing == '_all': raise utils.Failure("It does not make sense to ask for" " 'muddle query unused _all'") targets.append(depend.Label.from_string(thing)) else: print 'Using default deployables:' targets = buil... |
print 'Finding labels unused by:' | def _query_unused(self, builder, args): targets = [] print 'query unused %s'%args if args: for thing in args: if thing == '_all': raise utils.Failure("It does not make sense to ask for" " 'muddle query unused _all'") targets.append(depend.Label.from_string(thing)) else: print 'Using default deployables:' targets = buil... | |
def write(stamp_file1, stamp_file2, output_dir_name): | def write(our_stamp_file, far_stamp_file, output_dir_name): | def write(stamp_file1, stamp_file2, output_dir_name): output_dir = os.path.join(os.getcwd(), output_dir_name) output_dir = canonical_path(output_dir) if os.path.exists(output_dir): raise LocalError('Output directory %s already exists'%output_dir) stamp1 = VersionStamp.from_file(stamp_file1) stamp2 = VersionStamp.from... |
stamp1 = VersionStamp.from_file(stamp_file1) stamp2 = VersionStamp.from_file(stamp_file2) deleted, new, changed, problems = stamp1.compare(stamp2) | far_stamp = VersionStamp.from_file(far_stamp_file) our_stamp = VersionStamp.from_file(our_stamp_file) deleted, new, changed, problems = far_stamp.compare(our_stamp) | def write(stamp_file1, stamp_file2, output_dir_name): output_dir = os.path.join(os.getcwd(), output_dir_name) output_dir = canonical_path(output_dir) if os.path.exists(output_dir): raise LocalError('Output directory %s already exists'%output_dir) stamp1 = VersionStamp.from_file(stamp_file1) stamp2 = VersionStamp.from... |
directory = stamp1[name].dir repository = stamp1[name].repo | directory = our_stamp[name].dir repository = our_stamp[name].repo | def write(stamp_file1, stamp_file2, output_dir_name): output_dir = os.path.join(os.getcwd(), output_dir_name) output_dir = canonical_path(output_dir) if os.path.exists(output_dir): raise LocalError('Output directory %s already exists'%output_dir) stamp1 = VersionStamp.from_file(stamp_file1) stamp2 = VersionStamp.from... |
stamp1 = args[-3] stamp2 = args[-2] | our_stamp = args[-3] far_stamp = args[-2] | def main(args): if not args: raise LocalError('Must specify help, read or write as first argument') if args[0] in ('-help', '--help', '-h', 'help'): print __doc__ return PATCH_DIR = 'patches' if not os.path.isdir(os.path.join(os.getcwd(), '.muddle')): raise LocalError('** Oops - not at the top level of a muddle buil... |
if len(args) == 3 and stamp1 in ('-f', '-force'): | if len(args) == 3 and far_stamp in ('-f', '-force'): | def main(args): if not args: raise LocalError('Must specify help, read or write as first argument') if args[0] in ('-help', '--help', '-h', 'help'): print __doc__ return PATCH_DIR = 'patches' if not os.path.isdir(os.path.join(os.getcwd(), '.muddle')): raise LocalError('** Oops - not at the top level of a muddle buil... |
write(stamp1, stamp2, patch_dir) | write(our_stamp, far_stamp, patch_dir) | def main(args): if not args: raise LocalError('Must specify help, read or write as first argument') if args[0] in ('-help', '--help', '-h', 'help'): print __doc__ return PATCH_DIR = 'patches' if not os.path.isdir(os.path.join(os.getcwd(), '.muddle')): raise LocalError('** Oops - not at the top level of a muddle buil... |
:Syntax: stamp [<file>] :or: stamp force [<file>] :or: stamp force head [<file>] | :Syntax: stamp save [-f[orce]|-h[ead]] [<file>] :or: stamp restore <url_or_file> :or: stamp diff [-u[nified]|-c[ontext]|-n|-h[tml]] <file1> <file2> [<output_file>] Saving: stamp save [<switches>] [<file>] ---------------------------------------- | def do_subst(self, args): if len(args) != 3: raise utils.Failure("Syntax: subst [src] [xml] [dst]") src = args[0] xml_file = args[1] dst = args[2] |
if <file> is given, and does not end in '.stamp', then '.stamp' will be appended to it. If <file> is not given, then a name of the form <sha1-hash>.stamp will be used, where <sha1-hash> is a hexstring representation of the hash of the content of the file. | This is intended to be enough information to allow reconstruction of the entire build tree, as-is. If a <file> is specified, then output will be written to that file. If its name does not end in '.stamp', then '.stamp' will be appended to it. If a <file> is not specified, then a name of the form <sha1-hash>.stamp wil... | def do_subst(self, args): if len(args) != 3: raise utils.Failure("Syntax: subst [src] [xml] [dst]") src = args[0] xml_file = args[1] dst = args[2] |
determined for all checkouts) then the extension ".partial" will be used instead of ".stamp". This is intended to be enough information to allow reconstruction of all of the checkouts. If a checkout has local changes that have not been committed, or needs to be synchronised with the remote repository (in other words,... | determined for all checkouts, and neither '-force' nor '-head' was specified) then the extension ".partial" will be used instead of ".stamp". An attempt will be made to give useful information about what the problems are. If a file already exists with the name ultimately chosen, that file will be overwritten. If '-f'... | def do_subst(self, args): if len(args) != 3: raise utils.Failure("Syntax: subst [src] [xml] [dst]") src = args[0] xml_file = args[1] dst = args[2] |
def requires_build_tree(self): return True | def print_syntax(self): print """\ :Syntax: stamp save [-f[orce]|-h[ead]] [<file>] :or: stamp restore <url_or_file> :or: stamp diff [-u[nified]|-n|-h[tml]] <file1> <file2> [<output_file>] ("stamp restore" is an experimental synonym for "unstamp", which see) Try 'muddle help stamp' for more information.""" de... | def requires_build_tree(self): return True |
force_head = False | just_use_head = False | def with_build_tree(self, builder, local_pkgs, args): force = False force_head = False filename = None |
if args: if len(args) == 1: if args[0] == 'force': print 'Forcing revision ids when necessary/possible' force = True | if not args: self.print_syntax() return 2 word = args[0] rest = args[1:] if word == 'save': self.write_stamp_file(builder, local_pkgs, rest) elif word == 'diff': self.compare_stamp_files(rest) elif word == 'restore': print "Can't do 'muddle stamp restore' with a build tree" return 2 else: print "Unexpected 'stamp %s'"... | def with_build_tree(self, builder, local_pkgs, args): force = False force_head = False filename = None |
filename = args[0] elif len(args) == 2: if args[0] == 'force': force = True if args[1] == 'head': print 'Using HEAD for all checkouts' force_head = True else: print 'Forcing revision ids when necessary/possible' filename = args[1] else: print "Unexpected '%s'"%(" ".join(args)) print self.__doc__ | print "Unexpected '%s'"%word self.print_syntax() | def with_build_tree(self, builder, local_pkgs, args): force = False force_head = False filename = None |
elif len(args) == 3 and args[0] == 'force' and args[1] == 'head': print 'Using HEAD for all checkouts' | self.diff(file1, file2, diff_style, output_file) def write_stamp_file(self, builder, local_pkgs, args): force = False just_use_head = False filename = None while args: word = args[0] args = args[1:] if word in ('-f', '-force'): | def with_build_tree(self, builder, local_pkgs, args): force = False force_head = False filename = None |
force_head = True filename = args[2] | just_use_head = False elif word in ('-h', '-head'): just_use_head = True force = False elif word.startswith('-'): print "Unexpected switch '%s'"%word self.print_syntax() return 2 elif filename is None: filename = word | def with_build_tree(self, builder, local_pkgs, args): force = False force_head = False filename = None |
print "Unexpected '%s'"%(" ".join(args)) print self.__doc__ | print "Unexpected '%s'"%word self.print_syntax() | def with_build_tree(self, builder, local_pkgs, args): force = False force_head = False filename = None |
if force_head: | if just_use_head: | def with_build_tree(self, builder, local_pkgs, args): force = False force_head = False filename = None |
print 'Saving data as %s'%filename | print 'Retrieving %s'%filename | def without_build_tree(self, muddle_binary, root_path, args): if len(args) != 1: print 'Syntax: unstamp <file>|<url>' return 2 |
raise Error("Command '%s' execution failed - %d"%(cmd,rv)) | raise Error("Command '%s' execution failed - %d"%(cmd,returncode)) | def get_cmd_data(cmd, env=None, isSystem=False, fold_stderr=True, verbose=False, fail_nonzero=True): """ Run the given command, and return its (returncode, stdout, stderr). If 'fold_stderr', then "fold" stderr into stdout, and return (returncode, stdout_data, NONE). If 'fail_nonzero' then if the return code is non-0,... |
raise Failure("Command '%s' execution failed - %d"%(cmd,rv)) | raise Failure("Command '%s' execution failed - %d"%(cmd,returncode)) | def get_cmd_data(cmd, env=None, isSystem=False, fold_stderr=True, verbose=False, fail_nonzero=True): """ Run the given command, and return its (returncode, stdout, stderr). If 'fold_stderr', then "fold" stderr into stdout, and return (returncode, stdout_data, NONE). If 'fail_nonzero' then if the return code is non-0,... |
self.bzr_repo, self.checkout_name)) | self.bzr_repo, self.checkout_name), env=self._derive_env()) | def check_out(self): # If we do "checkout" and then "unbind", then (a) we've made a non-standard # branch and then converted it into a standard one (!), but (b) we've lost # the linkage to the original repository, and so ``bzr revno`` will report # HEAD until after our first pull or push. Moreover, we'll need to tell #... |
utils.run_cmd("bzr pull %s"%self.bzr_repo) | utils.run_cmd("bzr pull %s"%self.bzr_repo, env=self._derive_env()) | def pull(self): update_in = os.path.join(self.checkout_path, self.checkout_name) os.chdir(update_in) utils.run_cmd("bzr pull %s"%self.bzr_repo) |
utils.run_cmd("bzr update", allowFailure = True) | utils.run_cmd("bzr update", allowFailure=True, env=self._derive_env()) | def update(self): update_in = os.path.join(self.checkout_path, self.checkout_name) os.chdir(update_in) utils.run_cmd("bzr update", allowFailure = True) |
utils.run_cmd("bzr commit", allowFailure = True) | utils.run_cmd("bzr commit", allowFailure=True, env=self._derive_env()) | def commit(self): commit_in = os.path.join(self.checkout_path, self.checkout_name) os.chdir(commit_in) utils.run_cmd("bzr commit", allowFailure = True) |
utils.run_cmd("bzr push %s"%self.bzr_repo) | utils.run_cmd("bzr push %s"%self.bzr_repo, env=self._derive_env()) | def push(self): push_in = os.path.join(self.checkout_path, self.checkout_name) os.chdir(push_in) print "> push to %s "%self.bzr_repo utils.run_cmd("bzr push %s"%self.bzr_repo) |
env = os.environ.copy() if 'PYTHONPATH' in env: del env['PYTHONPATH'] | env = self._derive_env() | def revision_to_checkout(self, force=False, verbose=False): """ Determine a revision id for this checkout, usable to check it out again. |
if work_in in sys.path: saved_sys_path = sys.path[:] while work_in in sys.path: sys.path.remove(work_in) sys_path_altered = True | retcode, text, ignore = utils.get_cmd_data('bzr version-info --check-clean', env=env, fold_stderr=False) if 'clean: False' in text: if force: print "'bzr version-info --check-clean' reports" \ " checkout '%s' has uncommitted data (ignoring it)"%self.checkout_name else: raise utils.Failure("'bzr version-info --check-cle... | def revision_to_checkout(self, force=False, verbose=False): """ Determine a revision id for this checkout, usable to check it out again. |
sys_path_altered = False try: retcode, text, ignore = utils.get_cmd_data('bzr version-info --check-clean', fold_stderr=False) if 'clean: False' in text: if force: print "'bzr version-info --check-clean' reports" \ " checkout '%s' has uncommitted data (ignoring it)"%self.checkout_name else: raise utils.Failure("'bzr v... | raise utils.Failure("'bzr revno' reports checkout '%s' has revision" " '%s', which is not an integer"%(self.checkout_name,revision)) | def revision_to_checkout(self, force=False, verbose=False): """ Determine a revision id for this checkout, usable to check it out again. |
utils.run_cmd("git config remote.origin.url=%s"%self.git_repo) | def pull(self): os.chdir(self.co_path) | |
utils.run_cmd("git pull %s %s"%(self.git_repo, self.branch)) else: utils.run_cmd("git pull %s master"%(self.git_repo)) | utils.run_cmd("git pull origin %s"%self.branch) else: utils.run_cmd("git pull origin master") | def pull(self): os.chdir(self.co_path) |
utils.run_cmd("git push %s"%effective_branch) | utils.run_cmd("git push origin %s"%effective_branch) | def push(self): os.chdir(self.co_path) if (self.branch is not None): effective_branch = "remotes/origin/%s:%s" % (self.branch, self.branch) else: effective_branch = "" utils.run_cmd("git config remote.origin.url=%s"%self.git_repo) utils.run_cmd("git push %s"%effective_branch) |
print"get_checkout_path co_dir = %s"%self.checkout_dir | def get_checkout_path(self, co_name): """ When called with None, get the parent directory of this checkout. God knows what happens otherwise. .. todo:: Needs documenting and rewriting! """ | |
print 'File has SHA1 hash %s'%hash() | print 'File has SHA1 hash %s'%hash | def write_version_file(self, builder, args): force = False while args: word = args[0] args = args[1:] if word in ('-f', '-force'): force = True elif word.startswith('-'): print "Unexpected switch '%s'"%word self.print_syntax() return 2 else: print "Unexpected '%s'"%word self.print_syntax() return 2 |
output = utils.get_cmd_data("git status --porcelain") if output[1]!="": | output = utils.get_cmd_data("git status --porcelain", fail_nonzero=False) if output[0]==129: print "Warning: Your git doesn't support git status --porcelain; time to upgrade git?" output = utils.get_cmd_data("git status", fail_nonzero=False) if (output[1].find("working directory clean") < 0): repo_unclean = True else:... | def pull(self): os.chdir(self.co_path) |
output_dir = os.path.join(os.getcwd(), output_dir_name) | current_dir = os.getcwd() output_dir = os.path.join(current_dir, output_dir_name) | def write(our_stamp_file, far_stamp_file, output_dir_name): output_dir = os.path.join(os.getcwd(), output_dir_name) output_dir = canonical_path(output_dir) if os.path.exists(output_dir): raise LocalError('Output directory %s already exists'%output_dir) far_stamp = VersionStamp.from_file(far_stamp_file) our_stamp = Ve... |
our_stamp = VersionStamp.from_file(our_stamp_file) | def write(our_stamp_file, far_stamp_file, output_dir_name): output_dir = os.path.join(os.getcwd(), output_dir_name) output_dir = canonical_path(output_dir) if os.path.exists(output_dir): raise LocalError('Output directory %s already exists'%output_dir) far_stamp = VersionStamp.from_file(far_stamp_file) our_stamp = Ve... | |
parsed = urlparse(real_repo) | parsed = urlparse.urlparse(real_repo) | def __init__(self, inv, co_name, repo, rev, rel, co_dir): VersionControlHandler.__init__(self, inv, co_name, repo, rev, rel, co_dir) sp = conventional_repo_url(repo, rel) if (sp is None): raise utils.Error("Cannot extract repository URL from %s, co %s"%(repo, rel)) (real_repo, r) = sp |
from urlparse import urlparse | def manufacture(self, builder, co_name, repo, rev, rel, co_dir, branch): return File(builder, co_name, repo, rev, rel, co_dir) | |
result = urlparse(url) | result = urlparse.urlparse(url) | def _decode_file_url(url): result = urlparse(url) if result.scheme not in ('', 'file'): raise utils.Error("'%s' is not a valid 'file:' URL"%url) if result.netloc: raise utils.Error("'%s' is not a valid 'file:' URL - wrong number" " of '/' characters?"%url) if result.params or result.query or result.fragment: raise util... |
roster = self.client.getRoster() for jid in roster.getItems(): | for jid in self.client.roster.iterkeys(): | def users(self): """Users in the bot roster (administrators) |
if presence_type == "subscribed": | if presence_type == "subscribed" and who in self._initial_users: | def handle_presence(self, client, message): """ Handle the presence in XMPP server, this function is designed to work internally to bot, and handle the presence subscription XMPP message. """ |
if jid not in self.rooms and jid != self.jid: self.client.update_roster(jid, subscription="remove") | self.client.update_roster(jid, subscription="remove") | def unregister_user(self, jid): """Unregister an user as valid user for the bot.""" |
self.rooms = {} self.handlers = { EVENT_CONNECT: [], EVENT_DISCONNECT: [], EVENT_REGISTER: [], EVENT_JOIN: [], EVENT_LEAVE: [] } for room in rooms or []: self.rooms[room] = resource | def __init__(self, jid, password, server=None, rooms=None, resource=None, log=None, users=None): """Initialize a Whistler bot. | |
self.join(self.rooms.keys()) | [self.join_room(room) for room in self.rooms] | def handle_session_start(self, event): self.client.get_roster() self.client.send_presence() self.on_connect() |
self.client.RegisterHandler("presence", self.handle_error) resource = resource or self.resource or "whistler" while True: room_presence = xmpp.protocol.JID(node = room, domain = server, resource = resource) self.client.send(xmpp.protocol.Presence(room_presence)) self.rooms[u"%s@%s" % ( room, server ) ] = resource no_... | self.client.plugin["xep_0045"].joinMUC(room, resource or self.resource) | def join_room(self, room, server, resource=None): """Join a Multi-User Chat (MUC) room. |
self.client.UnregisterHandler("message", self.handle_message) self.client.UnregisterHandler("presence", self.handle_presence) | def disconnect(self): """Disconnect from the server. | |
self.client.disconnected() def leave_room(self, room, server, resource=None): | [self.leave_room(room) for room in self.rooms] self.client.disconnect() def leave_room(self, room, resource=None): | def disconnect(self): """Disconnect from the server. |
:param `server`: the server where room is. | def leave_room(self, room, server, resource=None): """ Perform an action to leave a room where currently the bot is in. | |
room_id = "%s@%s" % ( room, server) room_presence = xmpp.protocol.JID(node = room, domain=server, resource = resource or self.rooms[room_id]) self.client.send(xmpp.protocol.Presence(to=room_presence, typ="unavailable")) self.run_handler(EVENT_LEAVE, room_id) self.rooms.pop(room_id) | self.client.plugin["xep_0045"].leaveMUC(room, resource or self.resource) | def leave_room(self, room, server, resource=None): """ Perform an action to leave a room where currently the bot is in. |
"""Send a chat message to any user. This function is designed to be called from user custom handle functions, using :fun:`register_handler`. | """Send a chat message to an user. | def send_to(self, who, data): """Send a chat message to any user. |
dest = xmpp.JID(who) self.client.send( xmpp.protocol.Message(dest, data, "chat") ) | self.client.send_message(dest, data, mtype="chat") | def send_to(self, who, data): """Send a chat message to any user. |
if room in self.rooms.keys(): dest = xmpp.JID(room) | if room in self.rooms: | def set_subject(self, room, subject): """Set a new subject on specified room.""" |
self.client.send( xmpp.protocol.Message(dest, mesg, "groupchat", subject=subject) ) | self.client.send_message(room, mesg, subject, "groupchat") | def set_subject(self, room, subject): """Set a new subject on specified room.""" |
reply = command(message, arguments) | def send(self, message, command, arguments=[]): """ Send a XMPP message contains the result of command execution with arguments passed. The original message is also provided to known who sent the command. | |
user = "%s@%s" % (msg.getFrom().getNode(), msg.getFrom().getDomain()) | user = msg["from"].bare | def new(self, msg, args): user = "%s@%s" % (msg.getFrom().getNode(), msg.getFrom().getDomain()) if self.is_validuser(user): return fun(self, msg, args) else: self.log.warning("ignoring command %s, invalid user %s." % \ ( fun.__name__[4:], user )) |
if jid in self.rooms: return False if jid in self.client.roster(): return True else: return False | return jid not in self.rooms and jid in self.client.roster | def is_validuser(self, jid): """Check for whether an user is valid. |
U[s] = R(s) + gamma * sum([p * U[s] for (p, s1) in T(s, pi[s])]) | U[s] = R(s) + gamma * sum([p * U[s1] for (p, s1) in T(s, pi[s])]) | def policy_evaluation(pi, U, mdp, k=20): """Return an updated utility mapping U from each state in the MDP to its utility, using an approximation (modified policy iteration).""" R, T, gamma = mdp.R, mdp.T, mdp.gamma for i in range(k): for s in mdp.states: U[s] = R(s) + gamma * sum([p * U[s] for (p, s1) in T(s, pi[s])])... |
if screen_style_id is None and name.find('Summary') > 0: | if screen_style_id is None and name.find('ummary') > 0: | def lookupScreen(name, style_id): for (path, skin) in dom_skins: # first, find the corresponding screen element for x in skin.findall("screen"): if x.attrib.get('name', '') == name: screen_style_id = x.attrib.get('id', None) if screen_style_id is None and name.find('Summary') > 0: screen_style_id = 1 if screen_style_id... |
if screen_style_id is None or screen_style_id == style_id: | if screen_style_id is None or int(screen_style_id) == style_id: | def lookupScreen(name, style_id): for (path, skin) in dom_skins: # first, find the corresponding screen element for x in skin.findall("screen"): if x.attrib.get('name', '') == name: screen_style_id = x.attrib.get('id', None) if screen_style_id is None and name.find('Summary') > 0: screen_style_id = 1 if screen_style_id... |
def unpickle(self, lines): | def unpickle(self, lines, base_file=True): | def unpickle(self, lines): tree = { } for l in lines: if not l or l[0] == '#': continue |
names = l[:n].split('.') | names = name.split('.') | def unpickle(self, lines): tree = { } for l in lines: if not l or l[0] == '#': continue |
def loadFromFile(self, filename): | def loadFromFile(self, filename, base_file=False): | def loadFromFile(self, filename): f = open(filename, "r") self.unpickle(f.readlines()) f.close() |
self.unpickle(f.readlines()) | self.unpickle(f.readlines(), base_file) | def loadFromFile(self, filename): f = open(filename, "r") self.unpickle(f.readlines()) f.close() |
config.loadFromFile(self.CONFIG_FILE) | config.loadFromFile(self.CONFIG_FILE, True) | def load(self): try: config.loadFromFile(self.CONFIG_FILE) except IOError, e: print "unable to load config (%s), assuming defaults..." % str(e) |
if self.session.pipshown: self.session.pipshown = False del self.session.pip | if self.pipAvailable(): if self.session.pipshown: self.session.pipshown = False del self.session.pip | def stopService(self): self.oldref = self.session.nav.getCurrentlyPlayingServiceReference() self.session.nav.stopService() if self.session.pipshown: # try to disable pip self.session.pipshown = False del self.session.pip |
if path.realpath(parts[0]).startswith(self.dev_path): try: | real_path = path.realpath(parts[0]) if not real_path[-1].isdigit(): continue try: if MajorMinor(real_path) == MajorMinor(self.partitionPath(real_path[-1])): | def free(self): try: mounts = open("/proc/mounts") except IOError: return -1 |
except OSError: continue return stat.f_bfree/1000 * stat.f_bsize/1000 | return stat.f_bfree/1000 * stat.f_bsize/1000 except OSError: pass | def free(self): try: mounts = open("/proc/mounts") except IOError: return -1 |
for line in lines: parts = line.strip().split(" ") if path.realpath(parts[0]).startswith(self.dev_path): cmd = ' ' . join([cmd, parts[1]]) | for line in lines: parts = line.strip().split(" ") real_path = path.realpath(parts[0]) if not real_path[-1].isdigit(): continue try: if MajorMinor(real_path) == MajorMinor(self.partitionPath(real_path[-1])): cmd = ' ' . join([cmd, parts[1]]) break except OSError: pass | def unmount(self): try: mounts = open("/proc/mounts") except IOError: return -1 |
if path.realpath(parts[0]) == self.partitionPath("1"): cmd = "mount -t ext3 " + parts[0] res = system(cmd) break | real_path = path.realpath(parts[0]) if not real_path[-1].isdigit(): continue try: if MajorMinor(real_path) == MajorMinor(self.partitionPath(real_path[-1])): cmd = "mount -t ext3 " + parts[0] res = system(cmd) break except OSError: pass | def mount(self): try: fstab = open("/etc/fstab") except IOError: return -1 |
self.status = StaticText(_("Upgrading Dreambox... Please wait")) | self.status = StaticText(_("Please wait...")) | def __init__(self, session, args = None): Screen.__init__(self, session) |
self.package = StaticText() | self.package = StaticText(_("Verifying your internet connection...")) | def __init__(self, session, args = None): Screen.__init__(self, session) |
self.activityTimer.start(100, False) | def __init__(self, session, args = None): Screen.__init__(self, session) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.