bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
---|---|---|
def popitem(*args): raise NotImplementedError
|
def popitem(*args): raise NotImplementedError
| 479,800 |
def copy(self): """ Return a copy of the segmentlistdict object. The return value is a new object with a new offsets attribute, with references to the original keys, and shallow copies of the segment lists. Modifications made to the offset dictionary or segmentlists in the object returned by this method will not affect the original, but without using much memory until such modifications are made.
|
def copy(self): """ Return a copy of the segmentlistdict object. The return value is a new object with a new offsets attribute, with references to the original keys, and shallow copies of the segment lists. Modifications made to the offset dictionary or segmentlists in the object returned by this method will not affect the original, but without using much memory until such modifications are made.
| 479,801 |
def copy(self): """ Return a copy of the segmentlistdict object. The return value is a new object with a new offsets attribute, with references to the original keys, and shallow copies of the segment lists. Modifications made to the offset dictionary or segmentlists in the object returned by this method will not affect the original, but without using much memory until such modifications are made.
|
def copy(self): """ Return a copy of the segmentlistdict object. The return value is a new object with a new offsets attribute, with references to the original keys, and shallow copies of the segment lists. Modifications made to the offset dictionary or segmentlists in the object returned by this method will not affect the original, but without using much memory until such modifications are made.
| 479,802 |
def copy(self): """ Return a copy of the segmentlistdict object. The return value is a new object with a new offsets attribute, with references to the original keys, and shallow copies of the segment lists. Modifications made to the offset dictionary or segmentlists in the object returned by this method will not affect the original, but without using much memory until such modifications are made.
|
def copy(self): """ Return a copy of the segmentlistdict object. The return value is a new object with a new offsets attribute, with references to the original keys, and shallow copies of the segment lists. Modifications made to the offset dictionary or segmentlists in the object returned by this method will not affect the original, but without using much memory until such modifications are made.
| 479,803 |
def __init__(self, dag, job, cp, opts, time, ifo, p_nodes=[], type="ht", variety="fg"):
|
def __init__(self, dag, job, cp, opts, time, ifo, p_nodes=[], type="ht", variety="fg"):
| 479,804 |
def detector_thresholds(min_threshold, ifos, RA, dec, gps_time, sensitivities=None): """ Return a dictionary of sensitivity thresholds for each detector, based on a minimum threshold of min_threshold in the most sensitive one, for a source at position (RA,dec) specified in radians at time gps_time. Specifying a dictionary of sensitivities allows one to weight also by the relative SNR of a reference system in each detector to handle different noise curves. """ # Recurse if multiple RA, dec and GPS times are specified if type(gps_time)!=float or type(RA)!=float or type(dec)!=float: assert len(gps_time)==len(RA),len(gps_time)==len(dec) return map(lambda (a,b,c): detector_threshold(min_threshold,ifos,a,b,c,sensitivities), zip(RA,dec,gps_time)) from pylal import antenna # Sensitivies specifies relative SNRs of a reference signal (BNS) if sensitivities is None: sensitivities={} for det in ifos: sensitivies[det]=1.0 else: assert len(ifos)==len(sensitivites) # Normalise sensitivities minsens=min(sensitivities.values()) for det in ifos: sensitivities[det]/=minsens resps={} threshs={} # Make a dictionary of average responses for det in ifos: resps[det]=antenna.response(gps_time,RA,dec,0,0,'radians',det)[2] worst_resp=min(resps.values()) # Assuming that lowest threshold is in worst detector, return thresholds for det in ifos: threshs[det]=min_threshold*(resps[det]/worst_resp)*sensitivities[det] return threshs
|
def detector_thresholds(min_threshold, ifos, RA, dec, gps_time, sensitivities=None): """ Return a dictionary of sensitivity thresholds for each detector, based on a minimum threshold of min_threshold in the least sensitive one, for a source at position (RA,dec) specified in radians at time gps_time. Specifying a dictionary of sensitivities allows one to weight also by the relative SNR of a reference system in each detector to handle different noise curves. """ # Recurse if multiple RA, dec and GPS times are specified if type(gps_time)!=float or type(RA)!=float or type(dec)!=float: assert len(gps_time)==len(RA),len(gps_time)==len(dec) return map(lambda (a,b,c): detector_threshold(min_threshold,ifos,a,b,c,sensitivities), zip(RA,dec,gps_time)) from pylal import antenna # Sensitivies specifies relative SNRs of a reference signal (BNS) if sensitivities is None: sensitivities={} for det in ifos: sensitivies[det]=1.0 else: assert len(ifos)==len(sensitivites) # Normalise sensitivities minsens=min(sensitivities.values()) for det in ifos: sensitivities[det]/=minsens resps={} threshs={} # Make a dictionary of average responses for det in ifos: resps[det]=antenna.response(gps_time,RA,dec,0,0,'radians',det)[2] worst_resp=min(resps.values()) # Assuming that lowest threshold is in worst detector, return thresholds for det in ifos: threshs[det]=min_threshold*(resps[det]/worst_resp)*sensitivities[det] return threshs
| 479,805 |
def New(Type, columns = None): """ Convenience function for constructing pre-defined LSC tables. The optional columns argument is a list of the names of the columns the table should be constructed with. If columns = None, then the table is constructed with all valid columns included (pass columns = [] to create a table with no columns). Example: >>> tbl = New(ProcessTable) >>> tbl.write() """ new = Type(sax.xmlreader.AttributesImpl({u"Name": Type.tableName})) colnamefmt = u":".join(Type.tableName.split(":")[:-1]) + u":%s" if columns is not None: for key in columns: if key not in new.validcolumns: raise ligolw.ElementError, "invalid Column '%s' for Table '%s'" % (key, new.tableName) new.appendChild(table.Column(sax.xmlreader.AttributesImpl({u"Name": colnamefmt % key, u"Type": new.validcolumns[key]}))) else: for key, value in new.validcolumns.items(): new.appendChild(table.Column(sax.xmlreader.AttributesImpl({u"Name": colnamefmt % key, u"Type": value}))) new._end_of_columns() new.appendChild(table.TableStream(sax.xmlreader.AttributesImpl({u"Name": Type.tableName}))) return new
|
def New(Type, columns = None, **kwargs): """ Convenience function for constructing pre-defined LSC tables. The optional columns argument is a list of the names of the columns the table should be constructed with. If columns = None, then the table is constructed with all valid columns included (pass columns = [] to create a table with no columns). Example: >>> tbl = New(ProcessTable) >>> tbl.write() """ new = Type(sax.xmlreader.AttributesImpl({u"Name": Type.tableName})) colnamefmt = u":".join(Type.tableName.split(":")[:-1]) + u":%s" if columns is not None: for key in columns: if key not in new.validcolumns: raise ligolw.ElementError, "invalid Column '%s' for Table '%s'" % (key, new.tableName) new.appendChild(table.Column(sax.xmlreader.AttributesImpl({u"Name": colnamefmt % key, u"Type": new.validcolumns[key]}))) else: for key, value in new.validcolumns.items(): new.appendChild(table.Column(sax.xmlreader.AttributesImpl({u"Name": colnamefmt % key, u"Type": value}))) new._end_of_columns() new.appendChild(table.TableStream(sax.xmlreader.AttributesImpl({u"Name": Type.tableName}))) return new
| 479,806 |
def New(Type, columns = None): """ Convenience function for constructing pre-defined LSC tables. The optional columns argument is a list of the names of the columns the table should be constructed with. If columns = None, then the table is constructed with all valid columns included (pass columns = [] to create a table with no columns). Example: >>> tbl = New(ProcessTable) >>> tbl.write() """ new = Type(sax.xmlreader.AttributesImpl({u"Name": Type.tableName})) colnamefmt = u":".join(Type.tableName.split(":")[:-1]) + u":%s" if columns is not None: for key in columns: if key not in new.validcolumns: raise ligolw.ElementError, "invalid Column '%s' for Table '%s'" % (key, new.tableName) new.appendChild(table.Column(sax.xmlreader.AttributesImpl({u"Name": colnamefmt % key, u"Type": new.validcolumns[key]}))) else: for key, value in new.validcolumns.items(): new.appendChild(table.Column(sax.xmlreader.AttributesImpl({u"Name": colnamefmt % key, u"Type": value}))) new._end_of_columns() new.appendChild(table.TableStream(sax.xmlreader.AttributesImpl({u"Name": Type.tableName}))) return new
|
def New(Type, columns = None): """ Convenience function for constructing pre-defined LSC tables. The optional columns argument is a list of the names of the columns the table should be constructed with. If columns = None, then the table is constructed with all valid columns included (pass columns = [] to create a table with no columns). Example: >>> tbl = New(ProcessTable) >>> tbl.write() """ new = Type(sax.xmlreader.AttributesImpl({u"Name": Type.tableName}), **kwargs) colnamefmt = u":".join(Type.tableName.split(":")[:-1]) + u":%s" if columns is not None: for key in columns: if key not in new.validcolumns: raise ligolw.ElementError, "invalid Column '%s' for Table '%s'" % (key, new.tableName) new.appendChild(table.Column(sax.xmlreader.AttributesImpl({u"Name": colnamefmt % key, u"Type": new.validcolumns[key]}))) else: for key, value in new.validcolumns.items(): new.appendChild(table.Column(sax.xmlreader.AttributesImpl({u"Name": colnamefmt % key, u"Type": value}))) new._end_of_columns() new.appendChild(table.TableStream(sax.xmlreader.AttributesImpl({u"Name": Type.tableName}))) return new
| 479,807 |
def get_segments(connection, xmldoc, program_name): seglists = segments.segmentlistdict() if program_name == "thinca": seglists = db_thinca_rings.get_thinca_zero_lag_segments(connection, program_name) if program_name == "gstlal_inspiral" or program_name == "lalapps_ring": seglists = llwapp.segmentlistdict_fromsearchsummary(xmldoc, program_name).coalesce() return seglists
|
def get_segments(connection, xmldoc, program_name): seglists = segments.segmentlistdict() if program_name == "thinca": seglists = db_thinca_rings.get_thinca_zero_lag_segments(connection, program_name) if program_name == "gstlal_inspiral" or program_name == "lalapps_ring": seglists = llwapp.segmentlistdict_fromsearchsummary(xmldoc, program_name).coalesce() return seglists
| 479,808 |
def get_background_livetime_by_slide(connection, program_name, seglists, veto_segments=None, verbose = False): if program_name == "thinca": return background_livetime_ring_by_slide(connection, program_name, seglists, veto_segments, verbose) if program_name == "gstlal_inspiral": return background_livetime_nonring_by_slide(connection, seglists, veto_segments, verbose)
|
def get_background_livetime_by_slide(connection, program_name, seglists, veto_segments=None, verbose = False): if program_name == "thinca": return background_livetime_ring_by_slide(connection, program_name, seglists, veto_segments, verbose) if program_name == "gstlal_inspiral": return background_livetime_nonring_by_slide(connection, seglists, veto_segments, verbose)
| 479,809 |
def generate_git_version_info(): # info object info = git_info() git_path = check_call_out(('which', 'git')) # determine basic info about the commit # %H -- full git hash id # %ct -- commit time # %an, %ae -- author name, email # %cn, %ce -- committer name, email git_id, git_udate, git_author_name, git_author_email, \ git_committer_name, git_committer_email = \ check_call_out((git_path, 'log', '-1', '--pretty=format:%H,%ct,%an,%ae,%cn,%ce')).split(",") git_date = time.strftime('%Y-%m-%d %H:%M:%S +0000', time.gmtime(float(git_udate))) git_author = '%s <%s>' % (git_author_name, git_author_email) git_committer = '%s <%s>' % (git_committer_name, git_committer_email) # determine branch branch_match = check_call_out((git_path, 'rev-parse', '--symbolic-full-name', 'HEAD')) if branch_match == "HEAD": git_branch = None else: git_branch = os.path.basename(branch_match) # determine tag status, git_tag = call_out((git_path, 'describe', '--exact-match', '--tags', git_id)) if status != 0: git_tag = None # refresh index check_call_out((git_path, 'update-index', '-q', '--refresh')) # check working copy for changes status_output = subprocess.call((git_path, 'diff-files', '--quiet')) if status_output != 0: git_status = 'UNCLEAN: Modified working tree' else: # check index for changes status_output = subprocess.call((git_path, 'diff-index', '--cached', '--quiet', 'HEAD')) if status_output != 0: git_status = 'UNCLEAN: Modified index' else: git_status = 'CLEAN: All modifications committed' # determine version strings info.id = git_id info.date = git_date info.branch = git_branch info.tag = git_tag info.author = git_author info.committer = git_committer info.status = git_status return info
|
def generate_git_version_info(): # info object info = git_info() git_path = check_call_out(('which', 'git')) # determine basic info about the commit # %H -- full git hash id # %ct -- commit time # %an, %ae -- author name, email # %cn, %ce -- committer name, email git_id, git_udate, git_author_name, git_author_email, \ git_committer_name, git_committer_email = \ check_call_out((git_path, 'log', '-1', '--pretty=format:%H,%ct,%an,%ae,%cn,%ce')).split(",") git_date = time.strftime('%Y-%m-%d %H:%M:%S +0000', time.gmtime(float(git_udate))) git_author = '%s <%s>' % (git_author_name, git_author_email) git_committer = '%s <%s>' % (git_committer_name, git_committer_email) # determine branch branch_match = check_call_out((git_path, 'rev-parse', '--symbolic-full-name', 'HEAD')) if branch_match == "HEAD": git_branch = None else: git_branch = os.path.basename(branch_match) # determine tag status, git_tag = call_out((git_path, 'describe', '--exact-match', '--tags', git_id)) if status != 0: git_tag = None # refresh index check_call_out((git_path, 'update-index', '-q', '--refresh')) # check working copy for changes status_output = subprocess.call((git_path, 'diff-files', '--quiet')) if status_output != 0: git_status = 'UNCLEAN: Modified working tree' else: # check index for changes status_output = subprocess.call((git_path, 'diff-index', '--cached', '--quiet', 'HEAD')) if status_output != 0: git_status = 'UNCLEAN: Modified index' else: git_status = 'CLEAN: All modifications committed' # determine version strings info.id = git_id info.date = git_date info.branch = git_branch info.tag = git_tag info.author = git_author info.committer = git_committer info.status = git_status return info
| 479,810 |
def getinjpar(inj,parnum): if paramnames(parnum)=='mchirp': return inj.mchirp if paramname(parnum)=='eta': return inj.eta if paramname(parnum)=='time': return inj.get_end() if paramname(parnum)=='phi0': return inj.phi0 if paramname(parnum)=='dist': return inj.distance if paramname(parnum)=='RA': return inj.longitude if paramname(parnum)=='dec': return inj.latitude if paramname(parnum)=='psi': return inj.polarization if paramname(parnum)=='iota': return inj.inclination return None
|
def getinjpar(inj,parnum): if paramnames[parnum]=='mchirp': return inj.mchirp if paramnames[parnum]=='eta': return inj.eta if paramnames[parnum]=='time': return inj.get_end() if paramnames[parnum]=='phi0': return inj.phi0 if paramnames[parnum]=='dist': return inj.distance if paramnames[parnum]=='RA': return inj.longitude if paramnames[parnum]=='dec': return inj.latitude if paramnames[parnum]=='psi': return inj.polarization if paramnames[parnum]=='iota': return inj.inclination return None
| 479,811 |
def plot2Dkernel(xdat,ydat,Nx,Ny): xax=linspace(min(xdat),max(xdat),Nx) yax=linspace(min(ydat),max(ydat),Ny) x,y=numpy.meshgrid(xax,yax) samp=array([xdat,ydat]) kde=stats.kde.gaussian_kde(samp) grid_coords = numpy.append(x.reshape(-1,1),y.reshape(-1,1),axis=1) z = kde(grid_coords.T) z = z.reshape(Nx,Ny) asp=xax.ptp()/yax.ptp()
|
def plot2Dkernel(xdat,ydat,Nx,Ny): xax=linspace(min(xdat),max(xdat),Nx) yax=linspace(min(ydat),max(ydat),Ny) x,y=numpy.meshgrid(xax,yax) samp=array([xdat,ydat]) kde=stats.kde.gaussian_kde(samp) grid_coords = numpy.append(x.reshape(-1,1),y.reshape(-1,1),axis=1) z = kde(grid_coords.T) z = z.reshape(Nx,Ny) asp=xax.ptp()/yax.ptp()
| 479,812 |
def plot2Dkernel(xdat,ydat,Nx,Ny): xax=linspace(min(xdat),max(xdat),Nx) yax=linspace(min(ydat),max(ydat),Ny) x,y=numpy.meshgrid(xax,yax) samp=array([xdat,ydat]) kde=stats.kde.gaussian_kde(samp) grid_coords = numpy.append(x.reshape(-1,1),y.reshape(-1,1),axis=1) z = kde(grid_coords.T) z = z.reshape(Nx,Ny) asp=xax.ptp()/yax.ptp()
|
def plot2Dkernel(xdat,ydat,Nx,Ny): xax=linspace(min(xdat),max(xdat),Nx) yax=linspace(min(ydat),max(ydat),Ny) x,y=numpy.meshgrid(xax,yax) samp=array([xdat,ydat]) kde=stats.kde.gaussian_kde(samp) grid_coords = numpy.append(x.reshape(-1,1),y.reshape(-1,1),axis=1) z = kde(grid_coords.T) z = z.reshape(Nx,Ny) asp=xax.ptp()/yax.ptp()
| 479,813 |
def getSciSegs(ifo=None, gpsStart=None, gpsStop=None, cut=bool(False), serverURL=None, segName="DMT-SCIENCE", seglenmin=None, segpading=0
|
def getSciSegs(ifo=None, gpsStart=None, gpsStop=None, cut=bool(False), serverURL=None, segName="DMT-SCIENCE", seglenmin=None, segpading=0
| 479,814 |
def getSciSegs(ifo=None, gpsStart=None, gpsStop=None, cut=bool(False), serverURL=None, segName="DMT-SCIENCE", seglenmin=None, segpading=0
|
def getSciSegs(ifo=None, gpsStart=None, gpsStop=None, cut=bool(False), serverURL=None, segName="DMT-SCIENCE", seglenmin=None, segpading=0
| 479,815 |
def figure_out_cache(time,ifo): cacheList=( (home_dirs()+"/romain/followupbackgrounds/omega/S5/background/background_815155213_875232014.cache",815155213,875232014,"H1H2L1"), (home_dirs()+"/romain/followupbackgrounds/omega/S6a/background/background_931035296_935798415.cache",931035296,935798415,"H1L1"), (home_dirs()+"/romain/followupbackgrounds/omega/S6b/background/background_937800015_944587815.cache",935798415,944587815,"H1L1"), (home_dirs()+"/romain/followupbackgrounds/omega/S6b/background/background_944587815_947260815.cache",944587815,999999999,"H1L1"), (home_dirs()+"/romain/followupbackgrounds/omega/VSR2a/background/background_931035296_935798415.cache",931035296,935798415,"V1") (home_dirs()+"/romain/followupbackgrounds/omega/VSR2b/background/background_937800015_947260815.cache",935798415,999999999,"V1") ) foundCache = "" for cacheFile,start,stop,ifos in cacheList: if ((start<=time) and (time<stop) and ifo in ifos): foundCache = cacheFile break if 'phy.syr.edu' in get_hostname(): foundCache = foundCache.replace("romain","rgouaty") if foundCache == "": print ifo, time, " not found in method stfu_pipe.figure_out_cache" else: if not os.path.isfile(foundCache): print "file " + foundCache + " not found" foundCache = "" return foundCache
|
def figure_out_cache(time,ifo): cacheList=( (home_dirs()+"/romain/followupbackgrounds/omega/S5/background/background_815155213_875232014.cache",815155213,875232014,"H1H2L1"), (home_dirs()+"/romain/followupbackgrounds/omega/S6a/background/background_931035296_935798415.cache",931035296,935798415,"H1L1"), (home_dirs()+"/romain/followupbackgrounds/omega/S6b/background/background_937800015_944587815.cache",935798415,944587815,"H1L1"), (home_dirs()+"/romain/followupbackgrounds/omega/S6b/background/background_944587815_947260815.cache",944587815,999999999,"H1L1"), (home_dirs()+"/romain/followupbackgrounds/omega/VSR2a/background/background_931035296_935798415.cache",931035296,935798415,"V1"), (home_dirs()+"/romain/followupbackgrounds/omega/VSR2b/background/background_937800015_947260815.cache",935798415,999999999,"V1") ) foundCache = "" for cacheFile,start,stop,ifos in cacheList: if ((start<=time) and (time<stop) and ifo in ifos): foundCache = cacheFile break if 'phy.syr.edu' in get_hostname(): foundCache = foundCache.replace("romain","rgouaty") if foundCache == "": print ifo, time, " not found in method stfu_pipe.figure_out_cache" else: if not os.path.isfile(foundCache): print "file " + foundCache + " not found" foundCache = "" return foundCache
| 479,816 |
def run(self): # remove the automatically generated user env scripts for script in ["pylal-user-env.sh", "pylal-user-env.csh"]: log.info("removing " + script ) try: os.unlink(os.path.join("etc", script)) except: pass
|
def run(self): # remove the automatically generated user env scripts for script in ["pylal-user-env.sh", "pylal-user-env.csh"]: log.info("removing " + script ) try: os.unlink(os.path.join("etc", script)) except: pass
| 479,817 |
def __init__(self, dag, job, cp, opts, ifo, time, p_nodes=[], type=""):
|
def __init__(self, dag, job, cp, opts, ifo, time, p_nodes=[], type=""):
| 479,818 |
def __init__(self, dag, job, cp, opts, ifo, sngl=None, qscan=False, trigger_time=None, data_type="hoft", p_nodes=[]):
|
def __init__(self, dag, job, cp, opts, ifo, sngl=None, qscan=False, trigger_time=None, data_type="hoft", p_nodes=[]):
| 479,819 |
def __contains__(self, item): """ Returns True if the given object is wholly contained within one of the segments in self. If self has length n, then if item is a scalar or a segment this operation is O(log n), if it is a segmentlist of m segments this operation is O(m log n).
|
def __contains__(self, item): """ Returns True if the given object is wholly contained within the segments in self. If self has length n, then if item is a scalar or a segment this operation is O(log n), if item is a segmentlist of m segments this operation is O(m log n).
| 479,820 |
def __init__(self,cp,block_id,dagDir,channel=''): self.dagDirectory=dagDir self.__executable = cp.get('condor','clustertool') self.__universe= cp .get('condor','clustertool_universe') pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp) self.add_condor_cmd('getenv','True') self.block_id=blockID=block_id #layerID='RESULTS_'+str(blockID) layerID='RESULTS_'+channel+'_'+str(blockID) #Do not set channel name information here. This puts all #threshold output files into same place self.initialDir=layerPath=determineLayerPath(cp,blockID,layerID) blockPath=determineBlockPath(cp,blockID,channel) #Setup needed directories for this job to write in! buildDir(blockPath) buildDir(layerPath) buildDir(blockPath+'/logs') self.set_stdout_file(os.path.normpath(blockPath+'/logs/tracksearchThreshold-$(cluster)-$(process).out')) self.set_stderr_file(os.path.normpath(blockPath+'/logs/tracksearchThreshold-$(cluster)-$(process).err')) filename="/tracksearchThreshold--"+str(channel)+".sub" self.set_sub_file(os.path.normpath(self.dagDirectory+filename)) #Load in the cluster configuration sections! #Add the candidateUtils.py equivalent library to dag for proper #execution! self.candUtil=str(cp.get('pylibraryfiles','pyutilfile')) if ((self.__universe == 'scheduler') or (self.__universe == 'local')): self.add_condor_cmd('environment','PYTHONPATH=$PYTHONPATH:'+os.path.abspath(os.path.dirname(self.candUtil))) else: self.add_condor_cmd('should_transfer_files','yes') self.add_condor_cmd('when_to_transfer_output','on_exit') self.add_condor_cmd('transfer_input_files',self.candUtil) self.add_condor_cmd('initialdir',self.initialDir) #Setp escaping possible quotes in threshold string! optionTextList=[str('expression-threshold'),str('percentile-cut')] for optionText in optionTextList: oldVal=None if cp.has_option('candidatethreshold',optionText): oldVal=cp.get('candidatethreshold',optionText) newVal=str(oldVal) #New shell escape for latest condor 7.2.4 if newVal.__contains__('"'): newVal=str(newVal).replace('"','""') cp.set('candidatethreshold',optionText,newVal) for sec in ['candidatethreshold']: self.add_ini_opts(cp,sec) if oldVal != None: cp.set('candidatethreshold',optionText,oldVal)
|
def __init__(self,cp,block_id,dagDir,channel=''): self.dagDirectory=dagDir self.__executable = cp.get('condor','clustertool') self.__universe= cp .get('condor','clustertool_universe') pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp) self.add_condor_cmd('getenv','True') self.block_id=blockID=block_id #layerID='RESULTS_'+str(blockID) layerID='RESULTS_'+channel+'_'+str(blockID) #Do not set channel name information here. This puts all #threshold output files into same place self.initialDir=layerPath=determineLayerPath(cp,blockID,layerID) blockPath=determineBlockPath(cp,blockID,channel) #Setup needed directories for this job to write in! buildDir(blockPath) buildDir(layerPath) buildDir(blockPath+'/logs') self.set_stdout_file(os.path.normpath(blockPath+'/logs/tracksearchThreshold-$(cluster)-$(process).out')) self.set_stderr_file(os.path.normpath(blockPath+'/logs/tracksearchThreshold-$(cluster)-$(process).err')) filename="/tracksearchThreshold--"+str(channel)+".sub" self.set_sub_file(os.path.normpath(self.dagDirectory+filename)) #Load in the cluster configuration sections! #Add the candidateUtils.py equivalent library to dag for proper #execution! self.candUtil=str(cp.get('pylibraryfiles','pyutilfile')) if ((self.__universe == 'scheduler') or (self.__universe == 'local')): self.add_condor_cmd('environment','PYTHONPATH=$PYTHONPATH:'+os.path.abspath(os.path.dirname(self.candUtil))) else: self.add_condor_cmd('should_transfer_files','yes') self.add_condor_cmd('when_to_transfer_output','on_exit') self.add_condor_cmd('transfer_input_files',self.candUtil) self.add_condor_cmd('initialdir',self.initialDir) #Setp escaping possible quotes in threshold string! optionTextList=[str('expression-threshold'),str('percentile-cut')] for optionText in optionTextList: if cp.has_option('candidatethreshold',optionText): oldVal=cp.get('candidatethreshold',optionText) newVal=str(oldVal) #New shell escape for latest condor 7.2.4 if newVal.__contains__('"'): newVal=str(newVal).replace('"','""') cp.set('candidatethreshold',optionText,newVal) for sec in ['candidatethreshold']: self.add_ini_opts(cp,sec) if oldVal != None: cp.set('candidatethreshold',optionText,oldVal)
| 479,821 |
def __init__(self,cp,block_id,dagDir,channel=''): self.dagDirectory=dagDir self.__executable = cp.get('condor','clustertool') self.__universe= cp .get('condor','clustertool_universe') pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp) self.add_condor_cmd('getenv','True') self.block_id=blockID=block_id #layerID='RESULTS_'+str(blockID) layerID='RESULTS_'+channel+'_'+str(blockID) #Do not set channel name information here. This puts all #threshold output files into same place self.initialDir=layerPath=determineLayerPath(cp,blockID,layerID) blockPath=determineBlockPath(cp,blockID,channel) #Setup needed directories for this job to write in! buildDir(blockPath) buildDir(layerPath) buildDir(blockPath+'/logs') self.set_stdout_file(os.path.normpath(blockPath+'/logs/tracksearchThreshold-$(cluster)-$(process).out')) self.set_stderr_file(os.path.normpath(blockPath+'/logs/tracksearchThreshold-$(cluster)-$(process).err')) filename="/tracksearchThreshold--"+str(channel)+".sub" self.set_sub_file(os.path.normpath(self.dagDirectory+filename)) #Load in the cluster configuration sections! #Add the candidateUtils.py equivalent library to dag for proper #execution! self.candUtil=str(cp.get('pylibraryfiles','pyutilfile')) if ((self.__universe == 'scheduler') or (self.__universe == 'local')): self.add_condor_cmd('environment','PYTHONPATH=$PYTHONPATH:'+os.path.abspath(os.path.dirname(self.candUtil))) else: self.add_condor_cmd('should_transfer_files','yes') self.add_condor_cmd('when_to_transfer_output','on_exit') self.add_condor_cmd('transfer_input_files',self.candUtil) self.add_condor_cmd('initialdir',self.initialDir) #Setp escaping possible quotes in threshold string! optionTextList=[str('expression-threshold'),str('percentile-cut')] for optionText in optionTextList: oldVal=None if cp.has_option('candidatethreshold',optionText): oldVal=cp.get('candidatethreshold',optionText) newVal=str(oldVal) #New shell escape for latest condor 7.2.4 if newVal.__contains__('"'): newVal=str(newVal).replace('"','""') cp.set('candidatethreshold',optionText,newVal) for sec in ['candidatethreshold']: self.add_ini_opts(cp,sec) if oldVal != None: cp.set('candidatethreshold',optionText,oldVal)
|
def __init__(self,cp,block_id,dagDir,channel=''): self.dagDirectory=dagDir self.__executable = cp.get('condor','clustertool') self.__universe= cp .get('condor','clustertool_universe') pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp) self.add_condor_cmd('getenv','True') self.block_id=blockID=block_id #layerID='RESULTS_'+str(blockID) layerID='RESULTS_'+channel+'_'+str(blockID) #Do not set channel name information here. This puts all #threshold output files into same place self.initialDir=layerPath=determineLayerPath(cp,blockID,layerID) blockPath=determineBlockPath(cp,blockID,channel) #Setup needed directories for this job to write in! buildDir(blockPath) buildDir(layerPath) buildDir(blockPath+'/logs') self.set_stdout_file(os.path.normpath(blockPath+'/logs/tracksearchThreshold-$(cluster)-$(process).out')) self.set_stderr_file(os.path.normpath(blockPath+'/logs/tracksearchThreshold-$(cluster)-$(process).err')) filename="/tracksearchThreshold--"+str(channel)+".sub" self.set_sub_file(os.path.normpath(self.dagDirectory+filename)) #Load in the cluster configuration sections! #Add the candidateUtils.py equivalent library to dag for proper #execution! self.candUtil=str(cp.get('pylibraryfiles','pyutilfile')) if ((self.__universe == 'scheduler') or (self.__universe == 'local')): self.add_condor_cmd('environment','PYTHONPATH=$PYTHONPATH:'+os.path.abspath(os.path.dirname(self.candUtil))) else: self.add_condor_cmd('should_transfer_files','yes') self.add_condor_cmd('when_to_transfer_output','on_exit') self.add_condor_cmd('transfer_input_files',self.candUtil) self.add_condor_cmd('initialdir',self.initialDir) #Setp escaping possible quotes in threshold string! optionTextList=[str('expression-threshold'),str('percentile-cut')] for optionText in optionTextList: oldVal=None if cp.has_option('candidatethreshold',optionText): oldVal=cp.get('candidatethreshold',optionText) newVal=str(oldVal) #New shell escape for latest condor 7.2.4 if newVal.__contains__('"'): newVal=str(newVal).replace('"','""') cp.set('candidatethreshold',optionText,newVal) oldValList.append((optionText,oldVal)) for sec in ['candidatethreshold']: self.add_ini_opts(cp,sec) for myOpt,oldVal in oldValList: if oldVal != None: cp.set('candidatethreshold',optionText,oldVal)
| 479,822 |
def __init__(self,cp,block_id,dagDir,channel=''): self.dagDirectory=dagDir self.__executable = cp.get('condor','clustertool') self.__universe= cp .get('condor','clustertool_universe') pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp) self.add_condor_cmd('getenv','True') self.block_id=blockID=block_id #layerID='RESULTS_'+str(blockID) layerID='RESULTS_'+channel+'_'+str(blockID) #Do not set channel name information here. This puts all #threshold output files into same place self.initialDir=layerPath=determineLayerPath(cp,blockID,layerID) blockPath=determineBlockPath(cp,blockID,channel) #Setup needed directories for this job to write in! buildDir(blockPath) buildDir(layerPath) buildDir(blockPath+'/logs') self.set_stdout_file(os.path.normpath(blockPath+'/logs/tracksearchThreshold-$(cluster)-$(process).out')) self.set_stderr_file(os.path.normpath(blockPath+'/logs/tracksearchThreshold-$(cluster)-$(process).err')) filename="/tracksearchThreshold--"+str(channel)+".sub" self.set_sub_file(os.path.normpath(self.dagDirectory+filename)) #Load in the cluster configuration sections! #Add the candidateUtils.py equivalent library to dag for proper #execution! self.candUtil=str(cp.get('pylibraryfiles','pyutilfile')) if ((self.__universe == 'scheduler') or (self.__universe == 'local')): self.add_condor_cmd('environment','PYTHONPATH=$PYTHONPATH:'+os.path.abspath(os.path.dirname(self.candUtil))) else: self.add_condor_cmd('should_transfer_files','yes') self.add_condor_cmd('when_to_transfer_output','on_exit') self.add_condor_cmd('transfer_input_files',self.candUtil) self.add_condor_cmd('initialdir',self.initialDir) #Setp escaping possible quotes in threshold string! optionTextList=[str('expression-threshold'),str('percentile-cut')] for optionText in optionTextList: oldVal=None if cp.has_option('candidatethreshold',optionText): oldVal=cp.get('candidatethreshold',optionText) newVal=str(oldVal) #New shell escape for latest condor 7.2.4 if newVal.__contains__('"'): newVal=str(newVal).replace('"','""') cp.set('candidatethreshold',optionText,newVal) for sec in ['candidatethreshold']: self.add_ini_opts(cp,sec) if oldVal != None: cp.set('candidatethreshold',optionText,oldVal)
|
def __init__(self,cp,block_id,dagDir,channel=''): self.dagDirectory=dagDir self.__executable = cp.get('condor','clustertool') self.__universe= cp .get('condor','clustertool_universe') pipeline.CondorDAGJob.__init__(self,self.__universe,self.__executable) pipeline.AnalysisJob.__init__(self,cp) self.add_condor_cmd('getenv','True') self.block_id=blockID=block_id #layerID='RESULTS_'+str(blockID) layerID='RESULTS_'+channel+'_'+str(blockID) #Do not set channel name information here. This puts all #threshold output files into same place self.initialDir=layerPath=determineLayerPath(cp,blockID,layerID) blockPath=determineBlockPath(cp,blockID,channel) #Setup needed directories for this job to write in! buildDir(blockPath) buildDir(layerPath) buildDir(blockPath+'/logs') self.set_stdout_file(os.path.normpath(blockPath+'/logs/tracksearchThreshold-$(cluster)-$(process).out')) self.set_stderr_file(os.path.normpath(blockPath+'/logs/tracksearchThreshold-$(cluster)-$(process).err')) filename="/tracksearchThreshold--"+str(channel)+".sub" self.set_sub_file(os.path.normpath(self.dagDirectory+filename)) #Load in the cluster configuration sections! #Add the candidateUtils.py equivalent library to dag for proper #execution! self.candUtil=str(cp.get('pylibraryfiles','pyutilfile')) if ((self.__universe == 'scheduler') or (self.__universe == 'local')): self.add_condor_cmd('environment','PYTHONPATH=$PYTHONPATH:'+os.path.abspath(os.path.dirname(self.candUtil))) else: self.add_condor_cmd('should_transfer_files','yes') self.add_condor_cmd('when_to_transfer_output','on_exit') self.add_condor_cmd('transfer_input_files',self.candUtil) self.add_condor_cmd('initialdir',self.initialDir) #Setp escaping possible quotes in threshold string! optionTextList=[str('expression-threshold'),str('percentile-cut')] for optionText in optionTextList: oldVal=None if cp.has_option('candidatethreshold',optionText): oldVal=cp.get('candidatethreshold',optionText) newVal=str(oldVal) #New shell escape for latest condor 7.2.4 if newVal.__contains__('"'): newVal=str(newVal).replace('"','""') cp.set('candidatethreshold',optionText,newVal) for sec in ['candidatethreshold']: self.add_ini_opts(cp,sec) if oldVal != None: cp.set('candidatethreshold',optionText,oldVal)
| 479,823 |
def estimateDQbackground(self): """ This method looks at the self.resultlist inside the instance. Using this and 1000 generated time stamp it tabulates a ranking of flag prevelance, binomial probability 'p' """ if len(self.resultList) < 1: self.__backgroundResults__=list() self.__backgroundTimesDict__=dict() self.__backgroundDict__=dict() self.__haveBackgroundDict__=bool(False) return #Create DQ background, specify pickle locale to try and load first #Determine which IFOs from DQ listing uniqIfos=list() for ifo,b,c,d,e,f in self.resultList: if ifo not in uniqIfos: uniqIfos.append(ifo) ifoEpochList=[(x,getRunEpoch(self.triggerTime,x)) for x in self.ifos] self.createDQbackground(ifoEpochList,self.__backgroundPickle__) for x in self.ifos: if x not in self.__backgroundPickle__.keys(): sys.stderr.write("Could not either open or save DQ \
|
def estimateDQbackground(self): """ This method looks at the self.resultlist inside the instance. Using this and 1000 generated time stamp it tabulates a ranking of flag prevelance, binomial probability 'p' """ if len(self.resultList) < 1: self.__backgroundResults__=list() self.__backgroundTimesDict__=dict() self.__backgroundDict__=dict() self.__haveBackgroundDict__=bool(False) return #Create DQ background, specify pickle locale to try and load first #Determine which IFOs from DQ listing uniqIfos=list() for ifo,b,c,d,e,f in self.resultList: if ifo not in uniqIfos: uniqIfos.append(ifo) ifoEpochList=[(x,getRunEpoch(self.triggerTime,x)) for x in self.ifos] self.createDQbackground(ifoEpochList,self.__backgroundPickle__) for x in self.ifos: if x not in self.__backgroundPickle__.keys(): sys.stderr.write("Could not either open or save DQ \
| 479,824 |
... def __init__(self):
|
... def __init__(self):
| 479,825 |
... def invokeFactory(self, type, **kwargs):
|
... def invokeFactory(self, type, **kwargs):
| 479,826 |
... def objectIds(self):
|
... def objectIds(self):
| 479,827 |
... def objectIds(self):
|
... def objectIds(self):
| 479,828 |
... def objectIds(self):
|
... def objectIds(self):
| 479,829 |
... def objectIds(self):
|
... def objectIds(self):
| 479,830 |
... def objectIds(self):
|
... def objectIds(self):
| 479,831 |
... def objectIds(self):
|
... def objectIds(self):
| 479,832 |
def member_list(request, eid=None): if 'event' in request.REQUEST: return HttpResponseRedirect('/member_list/%s/' % request.REQUEST['event']) if request.method == 'POST': if not request.user.profile.is_admin: message(request, 'Error: you are not an administrator!') return HttpResponseRedirect('/member_list') action = request.POST['action'] if request.POST.get('eid','') != "-1": e = Event.objects.get(id=int(request.POST['eid'])) if e.is_team: t = Team(event=e, chapter=request.chapter) new_members = [] message(request, 'A new %s team was created.' % e.name) else: e = None for key, val in request.POST.items(): if key.startswith('id_'): # For each id field, check to see if the id has changed, and save if it has trash, id = key.split('_') u = User.objects.get(id=int(id)) if u.profile.indi_id != val: u.profile.indi_id = val u.profile.save() if key.startswith('edit_'): # For user checkboxes, perform the action selected on the selected users trash, id = key.split('_') u = User.objects.get(id=int(id)) if action == 'promote': u.profile.is_admin = True u.profile.is_member = True u.profile.save() message(request, '%s promoted to administrator.' % name(u)) log(request, 'user_edit', '%s promoted %s to an administrator.' % (name(request.user), name(u)), u) elif action == 'demote': if u == request.user: message(request, 'Error: you cannot demote yourself.') return HttpResponseRedirect('/member_list') u.profile.is_admin = False u.profile.is_member = True u.profile.save() message(request, '%s changed to normal member.' % name(u)) log(request, 'user_edit', '%s changed %s to a regular member.' % (name(request.user), name(u)), u) elif action == 'advisor': u.profile.is_admin = True u.profile.is_member = False u.profile.save() message(request, '%s changed to advisor.' % name(u)) log(request, 'user_edit', '%s changed %s to an advisor.' % (name(request.user), name(u)), u) elif action == 'delete': if u == request.user: message(request, 'Error: you cannot delete yourself.') return HttpResponseRedirect('/member_list') message(request, '%s deleted.' % name(u)) log(request, 'user_delete', "%s deleted %s's account." % (name(request.user), name(u))) u.delete() elif request.POST.get('eid','') != "-1": #u = User.objects.get(id=int(request.GET['uid'])) #e = Event.objects.get(id=int(request.POST['eid'])) if e.is_team: new_members.append(u) message(request, '%s was added to the new team.' % name(u)) else: u.events.add(e) message(request, '%s has been added to %s\'s events.' % (e.name, name(u))) log(request, 'event_add', '%s added %s to %s\'s events.' % (name(request.user), e.name, name(u)), affected=u) else: pass if e and e.is_team == True: t.captain = new_members[0] message(request, '%s was selected to be the team captain.' % name(t.captain)) t.save() for member in new_members: t.members.add(member) if request.GET.get('action') and request.user.profile.is_admin: action = request.GET.get('action') if action == 'remove_event': u = User.objects.get(id=int(request.GET['uid'])) e = Event.objects.get(id=int(request.GET['eid'])) u.events.remove(e) message(request, '%s has been removed from %s\'s events.' % (e.name, name(u))) log(request, 'event_remove', '%s removed %s from %s\'s events.' % (name(request.user), e.name, name(u)), affected=u) if eid is not None: e = Event.objects.get(id=eid) members = e.entrants else: members = User.objects.all() members = members.filter(profile__chapter=request.chapter, is_superuser=False) members = members.order_by('-profile__is_member', '-profile__is_admin', 'last_name') return render_template('member_list.mako',request, members=members, selected_event = eid, events=request.chapter.get_events(), )
|
def member_list(request, eid=None): if 'event' in request.REQUEST: return HttpResponseRedirect('/member_list/%s/' % request.REQUEST['event']) if request.method == 'POST': if not request.user.profile.is_admin: message(request, 'Error: you are not an administrator!') return HttpResponseRedirect('/member_list') action = request.POST['action'] if request.POST.get('eid','') != "-1": e = Event.objects.get(id=int(request.POST['eid'])) if e.is_team: t = Team(event=e, chapter=request.chapter) new_members = [] message(request, 'A new %s team was created.' % e.name) else: e = None for key, val in request.POST.items(): if key.startswith('id_'): # For each id field, check to see if the id has changed, and save if it has trash, id = key.split('_') try: u = User.objects.get(id=int(id)) except User.DoesNotExist: continue if u.profile.indi_id != val: u.profile.indi_id = val u.profile.save() if key.startswith('edit_'): # For user checkboxes, perform the action selected on the selected users trash, id = key.split('_') try: u = User.objects.get(id=int(id)) except User.DoesNotExist: continue if action == 'promote': u.profile.is_admin = True u.profile.is_member = True u.profile.save() message(request, '%s promoted to administrator.' % name(u)) log(request, 'user_edit', '%s promoted %s to an administrator.' % (name(request.user), name(u)), u) elif action == 'demote': if u == request.user: message(request, 'Error: you cannot demote yourself.') return HttpResponseRedirect('/member_list') u.profile.is_admin = False u.profile.is_member = True u.profile.save() message(request, '%s changed to normal member.' % name(u)) log(request, 'user_edit', '%s changed %s to a regular member.' % (name(request.user), name(u)), u) elif action == 'advisor': u.profile.is_admin = True u.profile.is_member = False u.profile.save() message(request, '%s changed to advisor.' % name(u)) log(request, 'user_edit', '%s changed %s to an advisor.' % (name(request.user), name(u)), u) elif action == 'delete': if u == request.user: message(request, 'Error: you cannot delete yourself.') return HttpResponseRedirect('/member_list') message(request, '%s deleted.' % name(u)) log(request, 'user_delete', "%s deleted %s's account." % (name(request.user), name(u))) u.delete() elif request.POST.get('eid','') != "-1": #u = User.objects.get(id=int(request.GET['uid'])) #e = Event.objects.get(id=int(request.POST['eid'])) if e.is_team: new_members.append(u) message(request, '%s was added to the new team.' % name(u)) else: u.events.add(e) message(request, '%s has been added to %s\'s events.' % (e.name, name(u))) log(request, 'event_add', '%s added %s to %s\'s events.' % (name(request.user), e.name, name(u)), affected=u) else: pass if e and e.is_team == True: t.captain = new_members[0] message(request, '%s was selected to be the team captain.' % name(t.captain)) t.save() for member in new_members: t.members.add(member) if request.GET.get('action') and request.user.profile.is_admin: action = request.GET.get('action') if action == 'remove_event': u = User.objects.get(id=int(request.GET['uid'])) e = Event.objects.get(id=int(request.GET['eid'])) u.events.remove(e) message(request, '%s has been removed from %s\'s events.' % (e.name, name(u))) log(request, 'event_remove', '%s removed %s from %s\'s events.' % (name(request.user), e.name, name(u)), affected=u) if eid is not None: e = Event.objects.get(id=eid) members = e.entrants else: members = User.objects.all() members = members.filter(profile__chapter=request.chapter, is_superuser=False) members = members.order_by('-profile__is_member', '-profile__is_admin', 'last_name') return render_template('member_list.mako',request, members=members, selected_event = eid, events=request.chapter.get_events(), )
| 479,833 |
def custom404(request): print request.user return render_template('errors/404.mako', request, parent='../base.mako' if request.user else '../layout.mako')
|
def custom404(request): print request.user return render_template('errors/404.mako', request, parent='../base.mako' if request.user.is_authenticated() else '../layout.mako')
| 479,834 |
def custom500(request): return render_template('errors/500.mako', request, parent='../base.mako' if request.user else '../layout.mako')
|
def custom500(request): return render_template('errors/500.mako', request, parent='../base.mako' if request.user.is_authenticated() else '../layout.mako')
| 479,835 |
def calendar(request): if 'chapter' not in request.GET: return HttpResponse('No chapter specified.') chapter = Chapter.objects.get(id=int(request.GET['chapter'])) if 'key' not in request.GET or chapter.calendar_key != request.GET['key']: return HttpResponse('Invalid key specified.') cal = vobject.iCalendar() cal.add('method').value = 'PUBLISH' # IE/Outlook needs this for event in chapter.calendar_events.filter(date__gte=datetime.date.today()): vevent = cal.add('vevent') vevent.add('summary').value = event.name vevent.add('dtstart').value = event.date icalstream = cal.serialize() response = HttpResponse(icalstream)#, mimetype='text/calendar') response['Filename'] = 'calendar.ics' # IE needs this response['Content-Disposition'] = 'attachment; filename=calendar.ics' return response
|
def calendar(request): if 'chapter' not in request.GET: return HttpResponse('No chapter specified.') chapter = Chapter.objects.get(id=int(request.GET['chapter'])) if 'key' not in request.GET or chapter.calendar_key != request.GET['key']: return HttpResponse('Invalid key specified.') cal = vobject.iCalendar() cal.add('method').value = 'PUBLISH' # IE/Outlook needs this for event in (chapter.link or chapter).calendar_events.filter(date__gte=datetime.date.today()): vevent = cal.add('vevent') vevent.add('summary').value = event.name vevent.add('dtstart').value = event.date icalstream = cal.serialize() response = HttpResponse(icalstream)#, mimetype='text/calendar') response['Filename'] = 'calendar.ics' # IE needs this response['Content-Disposition'] = 'attachment; filename=calendar.ics' return response
| 479,836 |
def reset_password(request): if request.method == 'POST': if 'username' in request.POST: try: user = User.objects.get(Q(username=request.POST['username']) | Q(email=request.POST['username'])) except User.DoesNotExist: return render_template('registration/request_reset.mako', request, error_msg='Unknown username or email address') t = get_template('email/reset_password.mako') body = t.render(name=user.first_name, chapter=user.profile.chapter.name, uid=user.id, token=get_token(user)) try: send_mail('TSAEvents Password Reset', body, '%s TSA <[email protected]>' % user.profile.chapter.name, [user.email], fail_silently=False) except SMTPException: return render_template('registration/request_reset.mako', request, error_msg='Unable to send email. Contact server administrator.') return render_template('registration/request_reset.mako', request, success_msg='Further instructions have been sent to your email address.') if 'password' in request.POST: uid = int(request.POST['user']) auth = request.POST.get('auth','') user = User.objects.get(id=uid) if not verify_token(user, auth): return render_template('registration/request_reset.mako', request, error_msg='Invalid authentication token. Try re-sending the email.') password = request.POST['password'] confirm_password = request.POST['password'] if password != confirm_password: return render_template('registration/perform_reset.mako', reques, user=uid, auth=auth , error_msg='Error: passwords do not match.') user.set_password(password) user = authenticate(username=user.username, password=password) login(request, user) message(request, 'New password set. You have been automatically logged in.') return HttpResponseRedirect('/') elif 'user' in request.GET: uid = int(request.GET['user']) auth = request.GET.get('auth','') user = User.objects.get(id=uid) if verify_token(user, auth): return render_template('registration/perform_reset.mako', request, uid=uid, auth=auth ) else: return render_template('registration/request_reset.mako', request, error_msg='Invalid authentication token. Try re-sending the email.') return render_template('registration/request_reset.mako', request)
|
def reset_password(request): if request.method == 'POST': if 'username' in request.POST: try: user = User.objects.get(Q(username=request.POST['username']) | Q(email=request.POST['username'])) except User.DoesNotExist: return render_template('registration/request_reset.mako', request, error_msg='Unknown username or email address') t = get_template('email/reset_password.mako') body = t.render(name=user.first_name, chapter=user.profile.chapter.name, uid=user.id, token=get_token(user)) try: send_mail('TSAEvents Password Reset', body, '%s TSA <[email protected]>' % user.profile.chapter.name, [user.email], fail_silently=False) except SMTPException: return render_template('registration/request_reset.mako', request, error_msg='Unable to send email. Contact server administrator.') return render_template('registration/request_reset.mako', request, success_msg='Further instructions have been sent to your email address.') if 'password' in request.POST: uid = int(request.POST['user']) auth = request.POST.get('auth','') user = User.objects.get(id=uid) if not verify_token(user, auth): return render_template('registration/request_reset.mako', request, error_msg='Invalid authentication token. Try re-sending the email.') password = request.POST['password'] confirm_password = request.POST['confirm_password'] if password != confirm_password: return render_template('registration/perform_reset.mako', reques, user=uid, auth=auth , error_msg='Error: passwords do not match.') user.set_password(password) user = authenticate(username=user.username, password=password) login(request, user) message(request, 'New password set. You have been automatically logged in.') return HttpResponseRedirect('/') elif 'user' in request.GET: uid = int(request.GET['user']) auth = request.GET.get('auth','') user = User.objects.get(id=uid) if verify_token(user, auth): return render_template('registration/perform_reset.mako', request, uid=uid, auth=auth ) else: return render_template('registration/request_reset.mako', request, error_msg='Invalid authentication token. Try re-sending the email.') return render_template('registration/request_reset.mako', request)
| 479,837 |
def reset_password(request): if request.method == 'POST': if 'username' in request.POST: try: user = User.objects.get(Q(username=request.POST['username']) | Q(email=request.POST['username'])) except User.DoesNotExist: return render_template('registration/request_reset.mako', request, error_msg='Unknown username or email address') t = get_template('email/reset_password.mako') body = t.render(name=user.first_name, chapter=user.profile.chapter.name, uid=user.id, token=get_token(user)) try: send_mail('TSAEvents Password Reset', body, '%s TSA <[email protected]>' % user.profile.chapter.name, [user.email], fail_silently=False) except SMTPException: return render_template('registration/request_reset.mako', request, error_msg='Unable to send email. Contact server administrator.') return render_template('registration/request_reset.mako', request, success_msg='Further instructions have been sent to your email address.') if 'password' in request.POST: uid = int(request.POST['user']) auth = request.POST.get('auth','') user = User.objects.get(id=uid) if not verify_token(user, auth): return render_template('registration/request_reset.mako', request, error_msg='Invalid authentication token. Try re-sending the email.') password = request.POST['password'] confirm_password = request.POST['password'] if password != confirm_password: return render_template('registration/perform_reset.mako', reques, user=uid, auth=auth , error_msg='Error: passwords do not match.') user.set_password(password) user = authenticate(username=user.username, password=password) login(request, user) message(request, 'New password set. You have been automatically logged in.') return HttpResponseRedirect('/') elif 'user' in request.GET: uid = int(request.GET['user']) auth = request.GET.get('auth','') user = User.objects.get(id=uid) if verify_token(user, auth): return render_template('registration/perform_reset.mako', request, uid=uid, auth=auth ) else: return render_template('registration/request_reset.mako', request, error_msg='Invalid authentication token. Try re-sending the email.') return render_template('registration/request_reset.mako', request)
|
def reset_password(request): if request.method == 'POST': if 'username' in request.POST: try: user = User.objects.get(Q(username=request.POST['username']) | Q(email=request.POST['username'])) except User.DoesNotExist: return render_template('registration/request_reset.mako', request, error_msg='Unknown username or email address') t = get_template('email/reset_password.mako') body = t.render(name=user.first_name, chapter=user.profile.chapter.name, uid=user.id, token=get_token(user)) try: send_mail('TSAEvents Password Reset', body, '%s TSA <[email protected]>' % user.profile.chapter.name, [user.email], fail_silently=False) except SMTPException: return render_template('registration/request_reset.mako', request, error_msg='Unable to send email. Contact server administrator.') return render_template('registration/request_reset.mako', request, success_msg='Further instructions have been sent to your email address.') if 'password' in request.POST: uid = int(request.POST['user']) auth = request.POST.get('auth','') user = User.objects.get(id=uid) if not verify_token(user, auth): return render_template('registration/request_reset.mako', request, error_msg='Invalid authentication token. Try re-sending the email.') password = request.POST['password'] confirm_password = request.POST['password'] if password != confirm_password: return render_template('registration/perform_reset.mako', request, user=uid, auth=auth , error_msg='Error: passwords do not match.') user.set_password(password) user = authenticate(username=user.username, password=password) login(request, user) message(request, 'New password set. You have been automatically logged in.') return HttpResponseRedirect('/') elif 'user' in request.GET: uid = int(request.GET['user']) auth = request.GET.get('auth','') user = User.objects.get(id=uid) if verify_token(user, auth): return render_template('registration/perform_reset.mako', request, uid=uid, auth=auth ) else: return render_template('registration/request_reset.mako', request, error_msg='Invalid authentication token. Try re-sending the email.') return render_template('registration/request_reset.mako', request)
| 479,838 |
def reset_password(request): if request.method == 'POST': if 'username' in request.POST: try: user = User.objects.get(Q(username=request.POST['username']) | Q(email=request.POST['username'])) except User.DoesNotExist: return render_template('registration/request_reset.mako', request, error_msg='Unknown username or email address') t = get_template('email/reset_password.mako') body = t.render(name=user.first_name, chapter=user.profile.chapter.name, uid=user.id, token=get_token(user)) try: send_mail('TSAEvents Password Reset', body, '%s TSA <[email protected]>' % user.profile.chapter.name, [user.email], fail_silently=False) except SMTPException: return render_template('registration/request_reset.mako', request, error_msg='Unable to send email. Contact server administrator.') return render_template('registration/request_reset.mako', request, success_msg='Further instructions have been sent to your email address.') if 'password' in request.POST: uid = int(request.POST['user']) auth = request.POST.get('auth','') user = User.objects.get(id=uid) if not verify_token(user, auth): return render_template('registration/request_reset.mako', request, error_msg='Invalid authentication token. Try re-sending the email.') password = request.POST['password'] confirm_password = request.POST['password'] if password != confirm_password: return render_template('registration/perform_reset.mako', reques, user=uid, auth=auth , error_msg='Error: passwords do not match.') user.set_password(password) user = authenticate(username=user.username, password=password) login(request, user) message(request, 'New password set. You have been automatically logged in.') return HttpResponseRedirect('/') elif 'user' in request.GET: uid = int(request.GET['user']) auth = request.GET.get('auth','') user = User.objects.get(id=uid) if verify_token(user, auth): return render_template('registration/perform_reset.mako', request, user=uid, auth=auth ) else: return render_template('registration/request_reset.mako', request, error_msg='Invalid authentication token. Try re-sending the email.') return render_template('registration/request_reset.mako', request)
|
def reset_password(request): if request.method == 'POST': if 'username' in request.POST: try: user = User.objects.get(Q(username=request.POST['username']) | Q(email=request.POST['username'])) except User.DoesNotExist: return render_template('registration/request_reset.mako', request, error_msg='Unknown username or email address') t = get_template('email/reset_password.mako') body = t.render(name=user.first_name, chapter=user.profile.chapter.name, uid=user.id, token=get_token(user)) try: send_mail('TSAEvents Password Reset', body, '%s TSA <[email protected]>' % user.profile.chapter.name, [user.email], fail_silently=False) except SMTPException: return render_template('registration/request_reset.mako', request, error_msg='Unable to send email. Contact server administrator.') return render_template('registration/request_reset.mako', request, success_msg='Further instructions have been sent to your email address.') if 'password' in request.POST: uid = int(request.POST['user']) auth = request.POST.get('auth','') user = User.objects.get(id=uid) if not verify_token(user, auth): return render_template('registration/request_reset.mako', request, error_msg='Invalid authentication token. Try re-sending the email.') password = request.POST['password'] confirm_password = request.POST['password'] if password != confirm_password: return render_template('registration/perform_reset.mako', reques, user=uid, auth=auth , error_msg='Error: passwords do not match.') user.set_password(password) user = authenticate(username=user.username, password=password) login(request, user) message(request, 'New password set. You have been automatically logged in.') return HttpResponseRedirect('/') elif 'user' in request.GET: uid = int(request.GET['user']) auth = request.GET.get('auth','') user = User.objects.get(id=uid) if verify_token(user, auth): return render_template('registration/perform_reset.mako', request, uid=uid, auth=auth ) else: return render_template('registration/request_reset.mako', request, error_msg='Invalid authentication token. Try re-sending the email.') return render_template('registration/request_reset.mako', request)
| 479,839 |
def run(self): self.success = False self._timeout_count = 0
|
def run(self): self.success = False self._timeout_count = 0
| 479,840 |
def _timeout_cb(self): if self.success: # dispose of previous waiters. return False self._timeout_count += 1 self.poll() if self._timeout_count >= self.timeout or self.success: try: if gtk.main_level(): gtk.main_quit() except RuntimeError: # In Mandriva RuntimeError exception is thrown # If, gtk.main was already quit pass return False return True
|
def _timeout_cb(self): if self.success: # dispose of previous waiters. return False self._timeout_count += 1 self.poll() if self._timeout_count >= self.timeout or self.success: try: if _main_loop: _main_loop.quit() else: if gtk.main_level(): gtk.main_quit() except RuntimeError: # In Mandriva RuntimeError exception is thrown # If, gtk.main was already quit pass return False return True
| 479,841 |
def _event_cb(self, event): self.event_cb(event) if self.success: try: if gtk.main_level(): gtk.main_quit() except RuntimeError: # In Mandriva RuntimeError exception is thrown # If, gtk.main was already quit pass
|
def _event_cb(self, event): self.event_cb(event) if self.success: try: if _main_loop: _main_loop.quit() else: if gtk.main_level(): gtk.main_quit() except RuntimeError: # In Mandriva RuntimeError exception is thrown # If, gtk.main was already quit pass
| 479,842 |
def generatemouseevent(self, x, y, eventType = 'b1c'): ''' Generate mouse event on x, y co-ordinates. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: int @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: int
|
def generatemouseevent(self, x, y, eventType = 'b1c'): """ Generate mouse event on x, y co-ordinates. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: int @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: int
| 479,843 |
def generatemouseevent(self, x, y, eventType = 'b1c'): ''' Generate mouse event on x, y co-ordinates. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: int @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: int
|
def generatemouseevent(self, x, y, eventType = 'b1c'): """ Generate mouse event on x, y co-ordinates. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: int @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: int
| 479,844 |
def mouseleftclick(self, window_name, object_name): ''' Mouse left click on an object. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
|
def mouseleftclick(self, window_name, object_name): """ Mouse left click on an object. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
| 479,845 |
def mouseleftclick(self, window_name, object_name): ''' Mouse left click on an object. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
|
def mouseleftclick(self, window_name, object_name): """ Mouse left click on an object. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
| 479,846 |
def mousemove(self, window_name, object_name): ''' Mouse move on an object. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
|
def mousemove(self, window_name, object_name): """ Mouse move on an object. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
| 479,847 |
def mousemove(self, window_name, object_name): ''' Mouse move on an object. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
|
def mousemove(self, window_name, object_name): """ Mouse move on an object. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
| 479,848 |
def mouserightclick(self, window_name, object_name): ''' Mouse right click on an object. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
|
def mouserightclick(self, window_name, object_name): """ Mouse right click on an object. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
| 479,849 |
def mouserightclick(self, window_name, object_name): ''' Mouse right click on an object. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
|
def mouserightclick(self, window_name, object_name): """ Mouse right click on an object. @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
| 479,850 |
def doubleclick(self, window_name, object_name): ''' Double click on the object @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
|
def doubleclick(self, window_name, object_name): """ Double click on the object @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
| 479,851 |
def doubleclick(self, window_name, object_name): ''' Double click on the object @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
|
def doubleclick(self, window_name, object_name): """ Double click on the object @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. Or menu heirarchy @type object_name: string
| 479,852 |
def __call__(self, *args, **kwargs): logger.debug('%s(%s)' % \ (self.__name, ', '.join(map(repr, args)+['%s=%s' % (k, repr(v)) for k, v in kwargs.items()]))) args += (kwargs,) return self.__send(self.__name, args)
|
def __call__(self, *args, **kwargs): logger.debug('%s(%s)' % \ (self.__name, ', '.join(map(repr, args)+['%s=%s' % (k, repr(v)) for k, v in kwargs.items()]))) args += (kwargs,) return self.__send(self.__name, args)
| 479,853 |
def __new__(cls, *args, **kwargs): if not cls._generated: cls._generated = True d = ldtp.__dict__ cls._wrapped_methods =[] for attr in d: if cls._isRemoteMethod(d[attr]) and cls._isRelevant(d[attr]): setted = attr if hasattr(cls, attr): setted = "_remote_"+setted cls._wrapped_methods.append(setted) setattr(cls, setted, d[attr]) return object.__new__(cls)
|
def __new__(cls, *args, **kwargs): if not cls._generated: cls._generated = True d = ldtp.__dict__ cls._wrapped_methods =[] for attr in d: if cls._isRemoteMethod(d[attr]): setted = attr if hasattr(cls, attr): setted = "_remote_"+setted cls._wrapped_methods.append(setted) setattr(cls, setted, d[attr]) return object.__new__(cls)
| 479,854 |
def getchild(self, child_name='', role=''): # TODO: Bad API choice. Inconsistent, should return object or list, # not both. UPDATE: Only returns first match. matches = self._remote_getchild(child_name, role, True) if matches: if role: return [Component(self._window_name, matches[0])] else: return Component(self._window_name, matches[0]) else: return None
|
def getchild(self, child_name='', role=''): # TODO: Bad API choice. Inconsistent, should return object or list, # not both. UPDATE: Only returns first match. matches = self._remote_getchild(child_name, role, True) if matches: if role: return [Component(self._window_name, matches[0])] else: return Component(self._window_name, matches[0]) else: return None
| 479,855 |
def _isRelevant(cls, obj): args = cls._listArgs(obj) return len(args) >= 2 and \ 'window_name' == args[0] and 'object_name' == args[1]
|
def _isRelevant(cls, obj): args = cls._listArgs(obj) return len(args) >= 2 and \ 'window_name' == args[0] and 'object_name' == args[1]
| 479,856 |
def __init__(self): lazy_load = True self._states = {} self._state_names = {} self._callback = {} self._window_uptime = {} self._callback_event = [] self._get_all_state_names() self._handle_table_cell = False self._desktop = pyatspi.Registry.getDesktop(0) if Utils.cached_apps is None: pyatspi.Registry.registerEventListener( self._on_window_event, 'window') Utils.cached_apps = list() if lazy_load: for app in self._desktop: if app is None: continue self.cached_apps.append(app)
|
def __init__(self): lazy_load = True self._states = {} self._state_names = {} self._window_uptime = {} self._callback_event = [] self._get_all_state_names() self._handle_table_cell = False self._desktop = pyatspi.Registry.getDesktop(0) if Utils.cached_apps is None: pyatspi.Registry.registerEventListener( self._on_window_event, 'window') Utils.cached_apps = list() if lazy_load: for app in self._desktop: if app is None: continue self.cached_apps.append(app)
| 479,857 |
def _list_apps(self): for app in list(self.cached_apps): if not app: continue yield app
|
def _list_apps(self): for app in self.cached_apps: if not app: continue yield app
| 479,858 |
def _list_guis(self): for app in list(self.cached_apps): if not app: continue try: for gui in app: if not gui: continue yield gui except LookupError: self.cached_apps.remove(app)
|
def _list_guis(self): for app in self.cached_apps: if not app: continue try: for gui in app: if not gui: continue yield gui except LookupError: self.cached_apps.remove(app)
| 479,859 |
def _match_name_to_acc(self, name, acc): try: if acc.name == name: return 1 _ldtpize_accessible_name = self._ldtpize_accessible(acc) _object_name = u'%s%s' % (_ldtpize_accessible_name[0], _ldtpize_accessible_name[1]) if _object_name == name: return 1 if self._glob_match(name, acc.name): return 1 if self._glob_match(name, _object_name): return 1 role = acc.getRole() if role == pyatspi.ROLE_FRAME or role == pyatspi.ROLE_DIALOG or \ role == pyatspi.ROLE_WINDOW or \ role == pyatspi.ROLE_FONT_CHOOSER or \ role == pyatspi.ROLE_FILE_CHOOSER or \ role == pyatspi.ROLE_ALERT or \ role == pyatspi.ROLE_COLOR_CHOOSER: strip = '( |\n)' else: strip = '( |:|\.|_|\n)' _tmp_name = re.sub(strip, '', name) if self._glob_match(_tmp_name, _object_name): return 1 if self._glob_match(_tmp_name, _ldtpize_accessible_name[1]): return 1 except: pass return 0
|
def _match_name_to_acc(self, name, acc): if acc.name == name: return 1 _ldtpize_accessible_name = self._ldtpize_accessible(acc) _object_name = u'%s%s' % (_ldtpize_accessible_name[0], _ldtpize_accessible_name[1]) if _object_name == name: return 1 if self._glob_match(name, acc.name): return 1 if self._glob_match(name, _object_name): return 1 role = acc.getRole() if role == pyatspi.ROLE_FRAME or role == pyatspi.ROLE_DIALOG or \ role == pyatspi.ROLE_WINDOW or \ role == pyatspi.ROLE_FONT_CHOOSER or \ role == pyatspi.ROLE_FILE_CHOOSER or \ role == pyatspi.ROLE_ALERT or \ role == pyatspi.ROLE_COLOR_CHOOSER: strip = '( |\n)' else: strip = '( |:|\.|_|\n)' _tmp_name = re.sub(strip, '', name) if self._glob_match(_tmp_name, _object_name): return 1 if self._glob_match(_tmp_name, _ldtpize_accessible_name[1]): return 1 return 0 def _match_name_to_appmap(self, name, acc): if self._glob_match(name, acc['key']): return 1 if self._glob_match(name, acc['obj_index']): return 1 if self._glob_match(name, acc['label_by']): return 1 if self._glob_match(name, acc['label']): return 1 obj_name = u'%s' % re.sub(' ', '', name) role = acc['class'] if role == 'frame' or role == 'dialog' or \ role == 'window' or \ role == 'font_chooser' or \ role == 'file_chooser' or \ role == 'alert' or \ role == 'color_chooser': strip = '( |\n)' else: strip = '( |:|\.|_|\n)' obj_name = re.sub(strip, '', name) if acc['label_by']: _tmp_name = re.sub(strip, '', acc['label_by']) if self._glob_match(obj_name, _tmp_name): return 1 _ldtpize_accessible_name = self._ldtpize_accessible(acc) _object_name = u'%s%s' % (_ldtpize_accessible_name[0], _ldtpize_accessible_name[1]) if _object_name == name: return 1 if self._glob_match(name, acc.name): return 1 if self._glob_match(name, _object_name): return 1 role = acc.getRole() if role == pyatspi.ROLE_FRAME or role == pyatspi.ROLE_DIALOG or \ role == pyatspi.ROLE_WINDOW or \ role == pyatspi.ROLE_FONT_CHOOSER or \ role == pyatspi.ROLE_FILE_CHOOSER or \ role == pyatspi.ROLE_ALERT or \ role == pyatspi.ROLE_COLOR_CHOOSER: strip = '( |\n)' else: strip = '( |:|\.|_|\n)' _tmp_name = re.sub(strip, '', name) if self._glob_match(_tmp_name, _object_name): return 1 if self._glob_match(_tmp_name, _ldtpize_accessible_name[1]): return 1 except: pass return 0
| 479,860 |
def _match_name_to_acc(self, name, acc): try: if acc.name == name: return 1 _ldtpize_accessible_name = self._ldtpize_accessible(acc) _object_name = u'%s%s' % (_ldtpize_accessible_name[0], _ldtpize_accessible_name[1]) if _object_name == name: return 1 if self._glob_match(name, acc.name): return 1 if self._glob_match(name, _object_name): return 1 role = acc.getRole() if role == pyatspi.ROLE_FRAME or role == pyatspi.ROLE_DIALOG or \ role == pyatspi.ROLE_WINDOW or \ role == pyatspi.ROLE_FONT_CHOOSER or \ role == pyatspi.ROLE_FILE_CHOOSER or \ role == pyatspi.ROLE_ALERT or \ role == pyatspi.ROLE_COLOR_CHOOSER: strip = '( |\n)' else: strip = '( |:|\.|_|\n)' _tmp_name = re.sub(strip, '', name) if self._glob_match(_tmp_name, _object_name): return 1 if self._glob_match(_tmp_name, _ldtpize_accessible_name[1]): return 1 except: pass return 0
|
def _match_name_to_acc(self, name, acc): try: if acc.name == name: return 1 if acc['label']: _tmp_name = re.sub(strip, '', acc['label']) if self._glob_match(obj_name, _tmp_name): return 1 if self._glob_match(name, acc.name): return 1 if self._glob_match(name, _object_name): return 1 role = acc.getRole() if role == pyatspi.ROLE_FRAME or role == pyatspi.ROLE_DIALOG or \ role == pyatspi.ROLE_WINDOW or \ role == pyatspi.ROLE_FONT_CHOOSER or \ role == pyatspi.ROLE_FILE_CHOOSER or \ role == pyatspi.ROLE_ALERT or \ role == pyatspi.ROLE_COLOR_CHOOSER: strip = '( |\n)' else: strip = '( |:|\.|_|\n)' _tmp_name = re.sub(strip, '', name) if self._glob_match(_tmp_name, _object_name): return 1 if self._glob_match(_tmp_name, _ldtpize_accessible_name[1]): return 1 except: pass return 0
| 479,861 |
def _match_name_to_acc(self, name, acc): try: if acc.name == name: return 1 _ldtpize_accessible_name = self._ldtpize_accessible(acc) _object_name = u'%s%s' % (_ldtpize_accessible_name[0], _ldtpize_accessible_name[1]) if _object_name == name: return 1 if self._glob_match(name, acc.name): return 1 if self._glob_match(name, _object_name): return 1 role = acc.getRole() if role == pyatspi.ROLE_FRAME or role == pyatspi.ROLE_DIALOG or \ role == pyatspi.ROLE_WINDOW or \ role == pyatspi.ROLE_FONT_CHOOSER or \ role == pyatspi.ROLE_FILE_CHOOSER or \ role == pyatspi.ROLE_ALERT or \ role == pyatspi.ROLE_COLOR_CHOOSER: strip = '( |\n)' else: strip = '( |:|\.|_|\n)' _tmp_name = re.sub(strip, '', name) if self._glob_match(_tmp_name, _object_name): return 1 if self._glob_match(_tmp_name, _ldtpize_accessible_name[1]): return 1 except: pass return 0
|
def _match_name_to_acc(self, name, acc): try: if acc.name == name: return 1 _ldtpize_accessible_name = self._ldtpize_accessible(acc) _object_name = u'%s%s' % (_ldtpize_accessible_name[0], _ldtpize_accessible_name[1]) if _object_name == name: return 1 if self._glob_match(name, acc.name): return 1 if self._glob_match(name, _object_name): return 1 role = acc.getRole() if role == pyatspi.ROLE_FRAME or role == pyatspi.ROLE_DIALOG or \ role == pyatspi.ROLE_WINDOW or \ role == pyatspi.ROLE_FONT_CHOOSER or \ role == pyatspi.ROLE_FILE_CHOOSER or \ role == pyatspi.ROLE_ALERT or \ role == pyatspi.ROLE_COLOR_CHOOSER: strip = '( |\n)' else: strip = '( |:|\.|_|\n)' _tmp_name = re.sub(strip, '', name) if self._glob_match(_tmp_name, _object_name): return 1 if self._glob_match(_tmp_name, _ldtpize_accessible_name[1]): return 1 except: pass return 0
| 479,862 |
def _list_objects(self, obj): if obj: yield obj for child in obj: if child and child.getRole() == pyatspi.ROLE_TABLE_CELL and \ not self._handle_table_cell: # In OO.o navigating table cells consumes more time # and resource break for c in self._list_objects(child): yield c
|
def _list_objects(self, obj): if obj: yield obj for child in obj: if child.getRole() == pyatspi.ROLE_TABLE_CELL and \ not self._handle_table_cell: # In OO.o navigating table cells consumes more time # and resource break for c in self._list_objects(child): yield c
| 479,863 |
def _list_objects(self, obj): if obj: yield obj for child in obj: if child and child.getRole() == pyatspi.ROLE_TABLE_CELL and \ not self._handle_table_cell: # In OO.o navigating table cells consumes more time # and resource break for c in self._list_objects(child): yield c
|
def _list_objects(self, obj): if obj: yield obj for child in obj: if child and child.getRole() == pyatspi.ROLE_TABLE_CELL and \ not self._handle_table_cell: # In OO.o navigating table cells consumes more time # and resource break for c in self._list_objects(child): yield c
| 479,864 |
def _get_combo_child_object_type(self, obj): """ This function will check for all levels and returns the first matching LIST / MENU type """ try: if obj: for child in obj: if not child: continue if child.childCount > 0: child_obj = self._get_combo_child_object_type(child) if child_obj: return child_obj if child.getRole() == pyatspi.ROLE_LIST: return child elif child.getRole() == pyatspi.ROLE_MENU: return child except: pass return None
|
def _get_combo_child_object_type(self, obj): """ This function will check for all levels and returns the first matching LIST / MENU type """ try: if obj: for child in obj: if not child: continue if child.childCount > 0: child_obj = self._get_combo_child_object_type(child) if child_obj: return child_obj if child.getRole() == pyatspi.ROLE_LIST: return child elif child.getRole() == pyatspi.ROLE_MENU: return child except: pass return None
| 479,865 |
def _get_child_object_type(self, obj, role_type): """ This function will check for all levels and returns the first matching role_type """ try: if obj and role_type: for child in obj: if not child: continue if child.childCount > 0: child_obj = self._get_child_object_type(child, role_type) if child_obj: return child_obj if child.getRole() == role_type: return child except: pass return None
|
def _get_child_object_type(self, obj, role_type): """ This function will check for all levels and returns the first matching role_type """ try: if obj and role_type: for child in obj: if not child: continue if child.childCount > 0: child_obj = self._get_child_object_type(child, role_type) if child_obj: return child_obj if child.getRole() == role_type: return child except: pass return None
| 479,866 |
def _get_menu_hierarchy(self, window_name, object_name): _menu_hierarchy = re.split(';', object_name) # Get handle of menu obj = self._get_object(window_name, _menu_hierarchy[0]) # Navigate all sub-menu under a menu for _menu in _menu_hierarchy[1:]: _flag = False for _child in self._list_objects(obj): if obj == _child: # if the given object and child object matches continue if self._match_name_to_acc(_menu, _child): obj = _child _flag = True break if not _flag: raise LdtpServerException ( "Menu item %s doesn't exist in hierarchy" % _menu) return obj
|
defif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] _get_menu_hierarchy(self,if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] window_name,if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] object_name):if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] _menu_hierarchyif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] =if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] re.split(';',if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] object_name)if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] #if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] Getif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] handleif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] ofif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] menuif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] objif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] =if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] self._get_object(window_name,if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] _menu_hierarchy[0])if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] #if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] Navigateif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] allif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] sub-menuif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] underif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] aif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] menuif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] forif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] _menuif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] inif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] _menu_hierarchy[1:]:if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] _flagif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] =if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] Falseif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] forif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] _childif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] inif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] self._list_objects(obj):if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] ifif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] objif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] ==if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] _child:if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] #if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] ifif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] theif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] givenif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] objectif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] andif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] childif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] objectif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] matchesif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] continueif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] ifif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] self._match_name_to_acc(_menu,if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] _child):if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] objif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] =if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] _childif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] _flagif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] =if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] Trueif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] breakif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] ifif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] notif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] _flag:if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] raiseif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] LdtpServerExceptionif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] (if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] "Menuif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] itemif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] %sif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] doesn'tif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] existif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] inif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] hierarchy"if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] %if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] _menu)if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] returnif not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] obj
| 479,867 |
def _get_menu_hierarchy(self, window_name, object_name): _menu_hierarchy = re.split(';', object_name) # Get handle of menu obj = self._get_object(window_name, _menu_hierarchy[0]) # Navigate all sub-menu under a menu for _menu in _menu_hierarchy[1:]: _flag = False for _child in self._list_objects(obj): if obj == _child: # if the given object and child object matches continue if self._match_name_to_acc(_menu, _child): obj = _child _flag = True break if not _flag: raise LdtpServerException ( "Menu item %s doesn't exist in hierarchy" % _menu) return obj
|
def_get_menu_hierarchy(self,window_name,object_name):_menu_hierarchy=re.split(';',object_name)#Gethandleofmenuobj=self._get_object(window_name,_menu_hierarchy[0])#Navigateallsub-menuunderamenufor_menuin_menu_hierarchy[1:]:_flag=Falsefor_childinself._list_objects(obj):ifobj==_child:#ifthegivenobjectandchildobjectmatchescontinueifself._match_name_to_acc(_menu,_child):obj=_child_flag=Truebreakifnot_flag:raiseLdtpServerException("Menuitem%sdoesn'texistinhierarchy"%_menu)returnobj
| 479,868 |
def _get_menu_hierarchy(self, window_name, object_name): _menu_hierarchy = re.split(';', object_name) # Get handle of menu obj = self._get_object(window_name, _menu_hierarchy[0]) # Navigate all sub-menu under a menu for _menu in _menu_hierarchy[1:]: _flag = False for _child in self._list_objects(obj): if obj == _child: # if the given object and child object matches continue if self._match_name_to_acc(_menu, _child): obj = _child _flag = True break if not _flag: raise LdtpServerException ( "Menu item %s doesn't exist in hierarchy" % _menu) return obj
|
def _get_menu_hierarchy(self, window_name, object_name): _menu_hierarchy = re.split(';', object_name) # Get handle of menu obj = self._get_object(window_name, _menu_hierarchy[0]) # Navigate all sub-menu under a menu for _menu in _menu_hierarchy[1:]: _flag = False for _child in self._list_objects(obj): if obj == _child: # if the given object and child object matches continue if self._match_name_to_acc(_menu, _child): obj = _child break if not _flag: raise LdtpServerException ( "Menu item %s doesn't exist in hierarchy" % _menu) return obj
| 479,869 |
def _get_menu_hierarchy(self, window_name, object_name): _menu_hierarchy = re.split(';', object_name) # Get handle of menu obj = self._get_object(window_name, _menu_hierarchy[0]) # Navigate all sub-menu under a menu for _menu in _menu_hierarchy[1:]: _flag = False for _child in self._list_objects(obj): if obj == _child: # if the given object and child object matches continue if self._match_name_to_acc(_menu, _child): obj = _child _flag = True break if not _flag: raise LdtpServerException ( "Menu item %s doesn't exist in hierarchy" % _menu) return obj
|
def _get_menu_hierarchy(self, window_name, object_name): _menu_hierarchy = re.split(';', object_name) # Get handle of menu obj = self._get_object(window_name, _menu_hierarchy[0]) # Navigate all sub-menu under a menu for _menu in _menu_hierarchy[1:]: _flag = False for _child in self._list_objects(obj): if obj == _child: # if the given object and child object matches continue if self._match_name_to_acc(_menu, _child): obj = _child _flag = True break if not _flag: raise LdtpServerException ( 'Menu item "%s" doesn\'t exist in hierarchy' % _menu) return obj
| 479,870 |
def _click_object(self, obj, action = 'click'): try: iaction = obj.queryAction() except NotImplementedError: raise LdtpServerException( 'Object does not have an Action interface') else: for i in xrange(iaction.nActions): if re.match(action, iaction.getName(i)): iaction.doAction(i) return raise LdtpServerException('Object does not have a "click" action')
|
def _click_object(self, obj, action = 'click'): try: iaction = obj.queryAction() except NotImplementedError: raise LdtpServerException( 'Object does not have an Action interface') else: for i in xrange(iaction.nActions): if re.match(action, iaction.getName(i)): iaction.doAction(i) return raise LdtpServerException('Object does not have a "click" action')
| 479,871 |
def _get_object_info(self, window_name, obj_name): _window_handle = self._get_window_handle(window_name) if not _window_handle: raise LdtpServerException('Unable to find window "%s"' % \ window_name) for name, obj, obj_index in self._appmap_pairs(_window_handle): if self._glob_match(obj_name, obj_index) or \ self._match_name_to_acc(obj_name, obj) or \ self._match_name_to_appmap(obj_name, name): return name, obj, obj_index raise LdtpServerException( 'Unable to find object name "%s" in application map' % obj_name)
|
def _get_object(self, window_name, obj_name): _window_handle = self._get_window_handle(window_name) if not _window_handle: raise LdtpServerException('Unable to find window "%s"' % \ window_name) for name, obj, obj_index in self._appmap_pairs(_window_handle): if self._glob_match(obj_name, obj_index) or \ self._match_name_to_acc(obj_name, obj) or \ self._match_name_to_appmap(obj_name, name): return name, obj, obj_index raise LdtpServerException( 'Unable to find object name "%s" in application map' % obj_name)
| 479,872 |
def _get_object_info(self, window_name, obj_name): _window_handle = self._get_window_handle(window_name) if not _window_handle: raise LdtpServerException('Unable to find window "%s"' % \ window_name) for name, obj, obj_index in self._appmap_pairs(_window_handle): if self._glob_match(obj_name, obj_index) or \ self._match_name_to_acc(obj_name, obj) or \ self._match_name_to_appmap(obj_name, name): return name, obj, obj_index raise LdtpServerException( 'Unable to find object name "%s" in application map' % obj_name)
|
def _get_object_info(self, window_name, obj_name): _window_handle = self._get_window_handle(window_name) if not _window_handle: raise LdtpServerException('Unable to find window "%s"' % \ window_name) for name, obj, obj_index in self._appmap_pairs(_window_handle): if self._glob_match(obj_name, obj_index) or \ self._match_name_to_acc(obj_name, obj) or \ self._match_name_to_appmap(obj_name, name): return name, obj, obj_index raise LdtpServerException( 'Unable to find object name "%s" in application map' % obj_name)
| 479,873 |
def __init__(self): lazy_load = True self._states = {} self._appmap = {} self._callback = {} self._state_names = {} self._window_uptime = {} self._callback_event = [] self._get_all_state_names() self._handle_table_cell = False self._desktop = pyatspi.Registry.getDesktop(0) if Utils.cached_apps is None: pyatspi.Registry.registerEventListener( self._on_window_event, 'window') # Above window event doesn't get called for # 'window:destroy', so registering it individually pyatspi.Registry.registerEventListener( self._on_window_event, 'window:destroy') # Notify on any changes in all windows, based on this info, # its decided, whether force_remap is required or not pyatspi.Registry.registerEventListener(self._obj_changed, 'object:children-changed') pyatspi.Registry.registerEventListener( self._obj_changed, 'object:property-change:accessible-name')
|
def __init__(self): lazy_load = True self._states = {} self._appmap = {} self._callback = {} self._state_names = {} self._window_uptime = {} self._callback_event = [] self._get_all_state_names() self._handle_table_cell = False self._desktop = pyatspi.Registry.getDesktop(0) if Utils.cached_apps is None: pyatspi.Registry.registerEventListener( self._on_window_event, 'window') # Above window event doesn't get called for # 'window:destroy', so registering it individually pyatspi.Registry.registerEventListener( self._on_window_event, 'window:destroy') # Notify on any changes in all windows, based on this info, # its decided, whether force_remap is required or not pyatspi.Registry.registerEventListener(self._obj_changed, 'object:children-changed') pyatspi.Registry.registerEventListener( self._obj_changed, 'object:property-change:accessible-name')
| 479,874 |
def launchapp(self, cmd, args = [], delay = 0, env = 1): ''' Launch application.
|
def launchapp(self, cmd, args = [], delay = 0, env = 1): ''' Launch application.
| 479,875 |
def _glob_match(self, pattern, string): return bool(re_match(glob_trans(pattern), string, re.M | re.U | re.L))
|
def _glob_match(self, pattern, string): return bool(re_match(glob_trans(pattern), string, re.M | re.U | re.L))
| 479,876 |
def _get_menu_hierarchy(self, window_name, object_name): _menu_hierarchy = re.split(';', object_name) if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] obj = self._get_object(window_name, _menu_hierarchy[0]) for _menu in _menu_hierarchy[1:]: _flag = False print 'obj', obj for _child in self._list_objects(obj): print '_child', _child if obj == _child: # if the given object and child object matches continue if self._match_name_to_acc(_menu, _child): _flag = True obj = _child break if not _flag: raise LdtpServerException ( 'Menu item "%s" doesn\'t exist in hierarchy' % _menu) return obj
|
def _get_menu_hierarchy(self, window_name, object_name): _menu_hierarchy = re.split(';', object_name) if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] obj = self._get_object(window_name, _menu_hierarchy[0]) for _menu in _menu_hierarchy[1:]: _flag = False for _child in self._list_objects(obj): print '_child', _child if obj == _child: # if the given object and child object matches continue if self._match_name_to_acc(_menu, _child): _flag = True obj = _child break if not _flag: raise LdtpServerException ( 'Menu item "%s" doesn\'t exist in hierarchy' % _menu) return obj
| 479,877 |
def _get_menu_hierarchy(self, window_name, object_name): _menu_hierarchy = re.split(';', object_name) if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] obj = self._get_object(window_name, _menu_hierarchy[0]) for _menu in _menu_hierarchy[1:]: _flag = False print 'obj', obj for _child in self._list_objects(obj): print '_child', _child if obj == _child: # if the given object and child object matches continue if self._match_name_to_acc(_menu, _child): _flag = True obj = _child break if not _flag: raise LdtpServerException ( 'Menu item "%s" doesn\'t exist in hierarchy' % _menu) return obj
|
def _get_menu_hierarchy(self, window_name, object_name): _menu_hierarchy = re.split(';', object_name) if not re.search('^mnu', _menu_hierarchy[0]): _menu_hierarchy[0] = 'mnu%s' % _menu_hierarchy[0] obj = self._get_object(window_name, _menu_hierarchy[0]) for _menu in _menu_hierarchy[1:]: _flag = False print 'obj', obj for _child in self._list_objects(obj): if obj == _child: # if the given object and child object matches continue if self._match_name_to_acc(_menu, _child): _flag = True obj = _child break if not _flag: raise LdtpServerException ( 'Menu item "%s" doesn\'t exist in hierarchy' % _menu) return obj
| 479,878 |
def _click_object(self, obj, action = 'click'): try: iaction = obj.queryAction() except NotImplementedError: raise LdtpServerException( 'Object does not have an Action interface') else: for i in xrange(iaction.nActions): if re.match(action, iaction.getName(i)): iaction.doAction(i) return raise LdtpServerException('Object does not have a "%s" action' % action)
|
def _click_object(self, obj, action = '(click|press|activate)'): try: iaction = obj.queryAction() except NotImplementedError: raise LdtpServerException( 'Object does not have an Action interface') else: for i in xrange(iaction.nActions): if re.match(action, iaction.getName(i)): iaction.doAction(i) return raise LdtpServerException('Object does not have a "%s" action' % action)
| 479,879 |
def getchild(self, child_name='', role=''): # TODO: Bad API choice. Inconsistent, should return object or list, # not both. UPDATE: Only returns first match. matches = self._remote_getchild(child_name, role, True) if matches: if role: return [Component(self._window_name, matches[0])] else: return Component(self._window_name, matches[0]) else: return None
|
def getchild(self, child_name='', role=''): # TODO: Bad API choice. Inconsistent, should return object or list, # not both. UPDATE: Only returns first match. matches = self._remote_getchild(child_name, role, True) if matches: if role: return [Component(self._window_name, matches[0])] else: return Component(self._window_name, matches[0]) else: return None
| 479,880 |
def imagecapture(self, window_name = None, x = 0, y = 0, width = None, height = None): ''' Captures screenshot of the whole desktop or given window @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param x: x co-ordinate value @type x: int @param y: y co-ordinate value @type y: int @param width: width co-ordinate value @type width: int @param height: height co-ordinate value @type height: int
|
def imagecapture(self, window_name = None, x = 0, y = 0, width = None, height = None): """ Captures screenshot of the whole desktop or given window @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param x: x co-ordinate value @type x: int @param y: y co-ordinate value @type y: int @param width: width co-ordinate value @type width: int @param height: height co-ordinate value @type height: int
| 479,881 |
def imagecapture(self, window_name = None, x = 0, y = 0, width = None, height = None): ''' Captures screenshot of the whole desktop or given window @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param x: x co-ordinate value @type x: int @param y: y co-ordinate value @type y: int @param width: width co-ordinate value @type width: int @param height: height co-ordinate value @type height: int
|
def imagecapture(self, window_name = None, x = 0, y = 0, width = None, height = None): """ Captures screenshot of the whole desktop or given window @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param x: x co-ordinate value @type x: int @param y: y co-ordinate value @type y: int @param width: width co-ordinate value @type width: int @param height: height co-ordinate value @type height: int
| 479,882 |
def _ebRender(self, failure): '''Custom error render method (used by our XMLRPC objects)''' if isinstance(failure.value, xmlrpclib.Fault): return failure.value
|
def _ebRender(self, failure): '''Custom error render method (used by our XMLRPC objects)''' if isinstance(failure.value, xmlrpclib.Fault): return failure.value
| 479,883 |
def _ebRender(self, failure): '''Custom error render method (used by our XMLRPC objects)''' if isinstance(failure.value, xmlrpclib.Fault): return failure.value
|
def _ebRender(self, failure): '''Custom error render method (used by our XMLRPC objects)''' if isinstance(failure.value, xmlrpclib.Fault): return failure.value
| 479,884 |
def _ebRender(self, failure): '''Custom error render method (used by our XMLRPC objects)''' if isinstance(failure.value, xmlrpclib.Fault): return failure.value
|
def _ebRender(self, failure): '''Custom error render method (used by our XMLRPC objects)''' if isinstance(failure.value, xmlrpclib.Fault): return failure.value
| 479,885 |
def imagecapture(self, window_name = None, x = 0, y = 0, width = None, height = None): ''' Captures screenshot of the whole desktop or given window @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param x: x co-ordinate value @type x: int @param y: y co-ordinate value @type y: int @param width: width co-ordinate value @type width: int @param height: height co-ordinate value @type height: int
|
def imagecapture(self, window_name = None, x = 0, y = 0, width = None, height = None): ''' Captures screenshot of the whole desktop or given window @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param x: x co-ordinate value @type x: int @param y: y co-ordinate value @type y: int @param width: width co-ordinate value @type width: int @param height: height co-ordinate value @type height: int
| 479,886 |
def getallstates(self, window_name, object_name): ''' Get all states of given object @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. @type object_name: string
|
def getallstates(self, window_name, object_name): ''' Get all states of given object @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. @type object_name: string
| 479,887 |
def getallstates(self, window_name, object_name): ''' Get all states of given object @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. @type object_name: string
|
def getallstates(self, window_name, object_name): ''' Get all states of given object @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. @type object_name: string
| 479,888 |
def hasstate(self, window_name, object_name, state): ''' has state @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. @type object_name: string
|
def hasstate(self, window_name, object_name, state): ''' has state @param window_name: Window name to look for, either full name, LDTP's name convention, or a Unix glob. @type window_name: string @param object_name: Object name to look for, either full name, LDTP's name convention, or a Unix glob. @type object_name: string
| 479,889 |
def _handle_signal(self, signum, frame): if os.environ.has_key('LDTP_DEBUG'): if signum == signal.SIGCHLD: print "ldtpd exited!" elif signum == signal.SIGUSR1: print "SIGUSR1 received. ldtpd ready for requests." elif signum == signal.SIGALRM: print "SIGALRM received. Timeout waiting for SIGUSR1."
|
def _handle_signal(self, signum, frame): if os.environ.has_key('LDTP_DEBUG'): if signum == signal.SIGCHLD: if _ldtp_debug: print "ldtpd exited!" elif signum == signal.SIGUSR1: print "SIGUSR1 received. ldtpd ready for requests." elif signum == signal.SIGALRM: print "SIGALRM received. Timeout waiting for SIGUSR1."
| 479,890 |
def _handle_signal(self, signum, frame): if os.environ.has_key('LDTP_DEBUG'): if signum == signal.SIGCHLD: print "ldtpd exited!" elif signum == signal.SIGUSR1: print "SIGUSR1 received. ldtpd ready for requests." elif signum == signal.SIGALRM: print "SIGALRM received. Timeout waiting for SIGUSR1."
|
def _handle_signal(self, signum, frame): if os.environ.has_key('LDTP_DEBUG'): if signum == signal.SIGCHLD: print "ldtpd exited!" elif signum == signal.SIGUSR1: if _ldtp_debug: print "SIGUSR1 received. ldtpd ready for requests." elif signum == signal.SIGALRM: print "SIGALRM received. Timeout waiting for SIGUSR1."
| 479,891 |
def _handle_signal(self, signum, frame): if os.environ.has_key('LDTP_DEBUG'): if signum == signal.SIGCHLD: print "ldtpd exited!" elif signum == signal.SIGUSR1: print "SIGUSR1 received. ldtpd ready for requests." elif signum == signal.SIGALRM: print "SIGALRM received. Timeout waiting for SIGUSR1."
|
def _handle_signal(self, signum, frame): if os.environ.has_key('LDTP_DEBUG'): if signum == signal.SIGCHLD: print "ldtpd exited!" elif signum == signal.SIGUSR1: print "SIGUSR1 received. ldtpd ready for requests." elif signum == signal.SIGALRM: print "SIGALRM received. Timeout waiting for SIGUSR1."
| 479,892 |
def _spawn_daemon(self): self._daemon = subprocess.Popen( ['python', '-c', 'import ldtpd; ldtpd.main()'], close_fds = True)
|
def _spawn_daemon(self): self._daemon = subprocess.Popen( ['python', '-c', 'import ldtpd; ldtpd.main()'], close_fds = True)
| 479,893 |
def kill_daemon(self): try: self._daemon.kill() except AttributeError: pass
|
def kill_daemon(self): try: os.kill(self._daemon, 9) except AttributeError: pass
| 479,894 |
def _get_all_children_under_obj(obj, child_list): if role and obj['class'] == role: child_list.append(obj['key']) elif child_name and self._match_name_to_appmap(child_name, obj): child_list.append(obj['key']) if obj: children = obj['children'] if not children: return child_list for child in children: return _get_all_children_under_obj( \ appmap[child], child_list)
|
def _get_all_children_under_obj(obj, child_list): if role and obj['class'] == role: child_list.append(obj['key']) elif child_name and self._match_name_to_appmap(child_name, obj): child_list.append(obj['key']) if obj: children = obj['children'] if not children: return child_list for child in children: return _get_all_children_under_obj( \ appmap[child], child_list)
| 479,895 |
def _get_all_children_under_obj(obj, child_list): if role and obj['class'] == role: child_list.append(obj['key']) elif child_name and self._match_name_to_appmap(child_name, obj): child_list.append(obj['key']) if obj: children = obj['children'] if not children: return child_list for child in children: return _get_all_children_under_obj( \ appmap[child], child_list)
|
def _get_all_children_under_obj(obj, child_list): if role and obj['class'] == role: child_list.append(obj['key']) elif child_name and self._match_name_to_appmap(child_name, obj): child_list.append(obj['key']) if obj: children = obj['children'] if not children: return child_list for child in children: return _get_all_children_under_obj( \ appmap[child], child_list)
| 479,896 |
def _get_child_object_type(self, obj, role_type): """ This function will check for all levels and returns the first matching role_type """ try: if obj and role_type: for child in obj: if not child: continue if child.childCount > 0: child_obj = self._get_child_object_type(child, role_type) if child_obj: return child_obj if child.getRole() == role_type: return child except: pass return None
|
def _get_child_object_type(self, obj, role_type): """ This function will check for all levels and returns the first matching role_type """ try: if obj and role_type: for child in obj: if not child: continue if child.childCount > 0: child_obj = self._get_child_object_type(child, role_type) if child_obj: return child_obj if child.getRole() == role_type: return child except: pass return None
| 479,897 |
def getcpustat(self, process_name): """ get CPU stat for the give process name
|
def getcpustat(self, process_name): """ get CPU stat for the give process name
| 479,898 |
def _match_name_to_acc(self, name, acc): if acc.name == name: return 1 _ldtpize_accessible_name = self._ldtpize_accessible(acc) _object_name = u'%s%s' % (_ldtpize_accessible_name[0], _ldtpize_accessible_name[1]) if _object_name == name: return 1 if self._glob_match(name, acc.name): return 1 if self._glob_match(name, _object_name): return 1 role = acc.getRole() if role == pyatspi.ROLE_FRAME or role == pyatspi.ROLE_DIALOG or \ role == pyatspi.ROLE_WINDOW or \ role == pyatspi.ROLE_FONT_CHOOSER or \ role == pyatspi.ROLE_FILE_CHOOSER or \ role == pyatspi.ROLE_ALERT or \ role == pyatspi.ROLE_COLOR_CHOOSER: strip = '( |\n)' else: strip = '( |:|\.|_|\n)' _tmp_name = re.sub(strip, '', name) if self._glob_match(_tmp_name, _object_name): return 1 if self._glob_match(_tmp_name, _ldtpize_accessible_name[1]): return 1 return 0
|
def _match_name_to_acc(self, name, acc): if acc.name == name: return 1 _ldtpize_accessible_name = self._ldtpize_accessible(acc) _object_name = u'%s%s' % (_ldtpize_accessible_name[0], _ldtpize_accessible_name[1]) if _object_name == name: return 1 if self._glob_match(name, acc.name): return 1 if self._glob_match(name, _object_name): return 1 role = acc.getRole() if role == pyatspi.ROLE_FRAME or role == pyatspi.ROLE_DIALOG or \ role == pyatspi.ROLE_WINDOW or \ role == pyatspi.ROLE_FONT_CHOOSER or \ role == pyatspi.ROLE_FILE_CHOOSER or \ role == pyatspi.ROLE_ALERT or \ role == pyatspi.ROLE_COLOR_CHOOSER: strip = '( |\n)' else: strip = '( |:|\.|_|\n)' _tmp_name = re.sub(strip, '', name) if self._glob_match(_tmp_name, _object_name): return 1 if self._glob_match(_tmp_name, _ldtpize_accessible_name[1]): return 1 return 0
| 479,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.