rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if self.forceFirstDate and xVals[0] != ticks[0]:
if self.forceFirstDate and firstDate!=ticks[0]:
def addTick(i, xVals=xVals, formatter=formatter, ticks=ticks, labels=labels): ticks.insert(0,xVals[i]) labels.insert(0,formatter(xVals[i]))
if self.forceEndDate and xVals[-1] != ticks[-1]: ticks.append(lastDate) labels.append(formatter(lastDate))
if (axisLength/float(ticks[-1]-ticks[0]))*(ticks[1]-ticks[0])<=W: if self.specialTickClear: labels[1] = '' else: del ticks[1], labels[1] if self.forceEndDate and endDate!=ticks[-1]: ticks.append(endDate) labels.append(formatter(endDate)) if (axisLength/float(ticks[-1]-ticks[0]))*(ticks[-1]-ticks[-2])<=W: if self.specia...
def addTick(i, xVals=xVals, formatter=formatter, ticks=ticks, labels=labels): ticks.insert(0,xVals[i]) labels.insert(0,formatter(xVals[i]))
j = xVals[-1].month() % (d<=12 and d or 12)
j = endDate.month() % (d<=12 and d or 12)
def addTick(i, xVals=xVals, formatter=formatter, ticks=ticks, labels=labels): ticks.insert(0,xVals[i]) labels.insert(0,formatter(xVals[i]))
wfd = xVals[0].month() == xVals[1].month()
wfd = firstDate.month() == xVals[1].month()
def addTick(i, xVals=xVals, formatter=formatter, ticks=ticks, labels=labels): ticks.insert(0,xVals[i]) labels.insert(0,formatter(xVals[i]))
if self.forceFirstDate and ticks[0] != xVals[0]:
if self.forceFirstDate and ticks[0]!=firstDate:
def addTick(i, xVals=xVals, formatter=formatter, ticks=ticks, labels=labels): ticks.insert(0,xVals[i]) labels.insert(0,formatter(xVals[i]))
A[e] += msg
if isinstance(v,IOError) and hasattr(v,'strerror'): v.strerror = msg+'\n'+v.strerror else: A[e] += msg
def annotateException(msg,enc='utf8'): '''add msg to the args of an existing exception''' if not msg: rise t,v,b=sys.exc_info() if not hasattr(v,'args'): raise e = -1 A = list(v.args) for i,a in enumerate(A): if isinstance(a,basestring): e = i break if e>=0: if isinstance(a,unicode): if not isinstance(msg,unicode): msg...
if self._wrapArgs==(availWidth,availHeight):
if self._wrapArgs==(availWidth,availHeight) and getattr(I,'_oldDrawSize',None) is None:
def wrap(self,availWidth,availHeight): canv = self.canv if hasattr(self,'_wrapArgs'): if self._wrapArgs==(availWidth,availHeight): return self.width,self.height self._reset() self._wrapArgs = availWidth, availHeight I = self._I I.wrap(availWidth,availHeight) wI, hI = I._restrictSize(availWidth,availHeight) self._wI = w...
I = self._I
def wrap(self,availWidth,availHeight): canv = self.canv if hasattr(self,'_wrapArgs'): if self._wrapArgs==(availWidth,availHeight): return self.width,self.height self._reset() self._wrapArgs = availWidth, availHeight I = self._I I.wrap(availWidth,availHeight) wI, hI = I._restrictSize(availWidth,availHeight) self._wI = w...
if self._wrapArgs!=(availWidth,availHeight):
I = self._I if self._wrapArgs!=(availWidth,availHeight) or getattr(I,'_oldDrawSize',None) is not None:
def split(self,availWidth, availHeight): if hasattr(self,'_wrapArgs'): if self._wrapArgs!=(availWidth,availHeight): self._reset() W,H=self.wrap(availWidth,availHeight) if self._aH>availHeight: return [] C1 = self._C1 if C1: c0 = C1[0] S = c0.split(availWidth,availHeight-self._aH) if not S: self._C1 = [] self.height = s...
x=x1, y=y1, width=x2-x1, height=y2-y1,
x=x, y=y, width=max(x1,x2)-x, height=max(y1,y2)-y,
def rect(self, x1,y1, x2,y2, rx=8, ry=8, link_info=None): "Draw a rectangle between x1,y1 and x2,y2."
args[-1] += '\ndocExec %s lifetime=%r failed!' % (stmt,lifetime)
msg = '\ndocExec %s lifetime=%r failed!' % (stmt,lifetime) args.append(msg)
def docExec(self,stmt,lifetime): stmt=stmt.strip() NS=self._nameSpace K0=NS.keys() try: if lifetime not in self._allowedLifetimes: raise ValueError('bad lifetime %r not in %r'%(lifetime,self._allowedLifetimes)) exec stmt in {},NS except: exc = sys.exc_info()[1] args = list(exc.args) args[-1] += '\ndocExec %s lifetime=%...
textColor = barFillColor = barStrokeColor = colors.black
textColor = barFillColor = colors.black barStrokeColor = None
def test(self,x): return type(x) is str and len(x)<=12 and len([c for c in x if c in "0123456789"])==12
lrect = Rect(x,yh,barWidth,barHeight-dh,fillColor=barFillColor,strokeWidth=barStrokeWidth,strokeColor=barFillColor)
lrect = Rect(x,yh,barWidth,barHeight-dh,fillColor=barFillColor,strokeWidth=barStrokeWidth,strokeColor=barStrokeColor)
def draw(self): g = Group() gAdd = g.add barWidth = self.barWidth width = self.width barHeight = self.barHeight x = self.x y = self.y gAdd(Rect(x,y,width,barHeight,fillColor=None,strokeColor=None,strokeWidth=0)) s = self.value+self._checkdigit(self.value) self._lquiet = lquiet = self._calc_quiet(self.lquiet) rquiet = s...
x -= numericXShift(text_anchor,text,textLen,font,fontSize)
x -= numericXShift(text_anchor,text,textLen,font,fontSize,encoding='winansi')
def drawString(self, stringObj): if self._canvas._fillColor: S = self._tracker.getState() text_anchor, x, y, text = S['textAnchor'], stringObj.x,stringObj.y,stringObj.text if not text_anchor in ['start','inherited']: font, fontSize = S['fontName'], S['fontSize'] textLen = stringWidth(text, font,fontSize) if text_anchor...
INFOLINES=[] def infoline(t): print t INFOLINES.append(t)
def pfxJoin(pfx,*N): R=[] for n in N: R.append(os.path.join(pfx,n)) return R
return os.path.isfile(ft_lib) and ft_lib or ''
return isfile(ft_lib) and ft_lib or ''
def check_ft_lib(ft_lib): if sys.hexversion<0x20000a0: return '' return os.path.isfile(ft_lib) and ft_lib or ''
self.parser.read(pjoin(pkgDir,'setup.cfg'))
self.parser.read(pjoin('setup.cfg'))
def __init__(self): try: self.parser = ConfigParser.RawConfigParser() self.parser.read(pjoin(pkgDir,'setup.cfg')) except: self.parser = None
os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))
os.chdir(dirname(abspath(sys.argv[0])))
def main(): cwd = os.getcwd() os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) MACROS=[('ROBIN_DEBUG',None)] MACROS=[] from glob import glob from distutils.core import setup, Extension pjoin=os.path.join RENDERPM=os.getcwd() LIBART_DIR=pjoin(RENDERPM,'libart_lgpl') GT1_DIR=pjoin(RENDERPM,'gt1') MACROS=[('ROBIN_...
pjoin=os.path.join
def main(): cwd = os.getcwd() os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) MACROS=[('ROBIN_DEBUG',None)] MACROS=[] from glob import glob from distutils.core import setup, Extension pjoin=os.path.join RENDERPM=os.getcwd() LIBART_DIR=pjoin(RENDERPM,'libart_lgpl') GT1_DIR=pjoin(RENDERPM,'gt1') MACROS=[('ROBIN_...
platform = sys.platform
def main(): cwd = os.getcwd() os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) MACROS=[('ROBIN_DEBUG',None)] MACROS=[] from glob import glob from distutils.core import setup, Extension pjoin=os.path.join RENDERPM=os.getcwd() LIBART_DIR=pjoin(RENDERPM,'libart_lgpl') GT1_DIR=pjoin(RENDERPM,'gt1') MACROS=[('ROBIN_...
if FT_LIB and not os.path.isfile(FT_LIB): infoline('
if FT_LIB and not isfile(FT_LIB): infoline('!!!!! freetype lib %r not found' % FT_LIB)
def libart_version(): K = ('LIBART_MAJOR_VERSION','LIBART_MINOR_VERSION','LIBART_MICRO_VERSION') D = {} for l in open(pjoin(LIBART_DIR,'configure.in'),'r').readlines(): l = l.strip().split('=') if len(l)>1 and l[0].strip() in K: D[l[0].strip()] = l[1].strip() if len(D)==3: break return (platform == 'win32' and '\\"%s\\...
if os.path.isdir(FT_INC_DIR[0]): infoline('
if isdir(FT_INC_DIR[0]): infoline('
def libart_version(): K = ('LIBART_MAJOR_VERSION','LIBART_MINOR_VERSION','LIBART_MICRO_VERSION') D = {} for l in open(pjoin(LIBART_DIR,'configure.in'),'r').readlines(): l = l.strip().split('=') if len(l)>1 and l[0].strip() in K: D[l[0].strip()] = l[1].strip() if len(D)==3: break return (platform == 'win32' and '\\"%s\\...
infoline('
infoline('!!!!! freetype2 include folder %r not found' % FT_INC_DIR[0])
def libart_version(): K = ('LIBART_MAJOR_VERSION','LIBART_MINOR_VERSION','LIBART_MICRO_VERSION') D = {} for l in open(pjoin(LIBART_DIR,'configure.in'),'r').readlines(): l = l.strip().split('=') if len(l)>1 and l[0].strip() in K: D[l[0].strip()] = l[1].strip() if len(D)==3: break return (platform == 'win32' and '\\"%s\\...
infoline(' infoline(' infoline(' infoline(' infoline('
infoline('!!!!! installing without freetype no ttf, sorry!') infoline('!!!!! You need to install a static library version of the freetype2 software') infoline('!!!!! If you need truetype support in renderPM') infoline('!!!!! You may need to edit setup.cfg (win32)') infoline('!!!!! or edit this file to access the librar...
def libart_version(): K = ('LIBART_MAJOR_VERSION','LIBART_MINOR_VERSION','LIBART_MICRO_VERSION') D = {} for l in open(pjoin(LIBART_DIR,'configure.in'),'r').readlines(): l = l.strip().split('=') if len(l)>1 and l[0].strip() in K: D[l[0].strip()] = l[1].strip() if len(D)==3: break return (platform == 'win32' and '\\"%s\\...
sn = 0
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] n = [] for l in self.data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) self._seriesCount = max(n) else: n...
for series in normData: i = 0 for angle in series:
for sn,series in enumerate(normData): for i,angle in enumerate(series):
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] n = [] for l in self.data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) self._seriesCount = max(n) else: n...
if abs(startAngle-endAngle)>=1e-5: if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle
if abs(startAngle-endAngle)<1e-5: startAngle = endAngle continue if startAngle < endAngle: a1 = startAngle a2 = endAngle else: a1 = endAngle a2 = startAngle startAngle = endAngle
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] n = [] for l in self.data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) self._seriesCount = max(n) else: n...
startAngle = endAngle
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] n = [] for l in self.data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) self._seriesCount = max(n) else: n...
i += 1 sn += 1
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] n = [] for l in self.data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) self._seriesCount = max(n) else: n...
i = 0
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] n = [] for l in self.data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) self._seriesCount = max(n) else: n...
for angle in normData:
for i,angle in enumerate(normData):
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] n = [] for l in self.data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) self._seriesCount = max(n) else: n...
startAngle = endAngle i += 1
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] n = [] for l in self.data: t = self.normalizeData(l) normData.append(t) n.append(len(t)) self._seriesCount = max(n) else: n...
g.add(xA) g.add(yA)
g.add(xA.draw()) g.add(yA.draw())
def draw(self): yA = self.yValueAxis xA = self.xValueAxis if getattr(self,'_bubblePlot',None): yA._bubblePlot = xA._bubblePlot = 1 yA.setPosition(self.x, self.y, self.height) if yA: yA.joinAxis = xA if xA: xA.joinAxis = yA yA.configure(self.data)
yAex = yA.visibleAxis and (xA._x,) or ()
yAex = yA.visibleAxis and (yA._x,) or ()
def draw(self): yA = self.yValueAxis xA = self.xValueAxis if getattr(self,'_bubblePlot',None): yA._bubblePlot = xA._bubblePlot = 1 yA.setPosition(self.x, self.y, self.height) if yA: yA.joinAxis = xA if xA: xA.joinAxis = yA yA.configure(self.data)
if (axisLength/(ticks[-1]-ticks[0]))*(ticks[1]-ticks[0])<=w:
if (axisLength/float(ticks[-1]-ticks[0]))*(ticks[1]-ticks[0])<=W:
def addTick(i, xVals=xVals, formatter=formatter, ticks=ticks, labels=labels): ticks.insert(0,xVals[i]) labels.insert(0,formatter(xVals[i]))
if (axisLength/(ticks[-1]-ticks[0]))*(ticks[-1]-ticks[-2])<=w:
if (axisLength/float(ticks[-1]-ticks[0]))*(ticks[-1]-ticks[-2])<=W:
def addTick(i, xVals=xVals, formatter=formatter, ticks=ticks, labels=labels): ticks.insert(0,xVals[i]) labels.insert(0,formatter(xVals[i]))
if communeLocalite and communeLocalite != '-1':
if communeLocalite and str(communeLocalite) != '-1':
def action_search(self, action, data): wrapper = getSAWrapper('gites_wallons') session = wrapper.session hebergementTable = wrapper.getMapper('hebergement') proprioTable = wrapper.getMapper('proprio') reservationsTable = wrapper.getMapper('reservation_proprio') provincesTable = wrapper.getMapper('province') communeTabl...
elif provinces and provinces != '-1':
elif provinces and str(provinces) != '-1':
def action_search(self, action, data): wrapper = getSAWrapper('gites_wallons') session = wrapper.session hebergementTable = wrapper.getMapper('hebergement') proprioTable = wrapper.getMapper('proprio') reservationsTable = wrapper.getMapper('reservation_proprio') provincesTable = wrapper.getMapper('province') communeTabl...
if hebergementType and hebergementType != -1:
if hebergementType and str(hebergementType) != '-1':
def action_search(self, action, data): wrapper = getSAWrapper('gites_wallons') session = wrapper.session hebergementTable = wrapper.getMapper('hebergement') proprioTable = wrapper.getMapper('proprio') reservationsTable = wrapper.getMapper('reservation_proprio') provincesTable = wrapper.getMapper('province') communeTabl...
if classification and classification != -1:
if classification and str(classification) != '-1':
def action_search(self, action, data): wrapper = getSAWrapper('gites_wallons') session = wrapper.session hebergementTable = wrapper.getMapper('hebergement') proprioTable = wrapper.getMapper('proprio') reservationsTable = wrapper.getMapper('reservation_proprio') provincesTable = wrapper.getMapper('province') communeTabl...
heb_maj_animal=fields.get('heb_maj_animal'),\
def insertHebergementMaj(self): """ ajoute les infos de mise à jour de l'hébergement par le proprio table habergement_maj met dans table hebergement le champ heb_maj_info_etat à 'En attente de confirmation' """ fields = self.context.REQUEST chargeFk=fields.get('heb_maj_charge_fk') hebPk=fields.get('heb_maj_hebpk') hebN...
heb_maj_tenis_distance=fields.get('heb_maj_tenis_distance', 0),\ heb_maj_nautisme_distance=fields.get('heb_maj_nautisme_distance', 0),\ heb_maj_sky_distance=fields.get('heb_maj_sky_distance', 0),\ heb_maj_rando_distance=fields.get('heb_maj_rando_distance', 0),\ heb_maj_piscine_distance=fields.get('heb_maj_piscine_dista...
heb_maj_animal=fields.get('heb_maj_animal'),\ heb_maj_tenis_distance=fields.get('heb_maj_tenis_distance'),\ heb_maj_nautisme_distance=fields.get('heb_maj_nautisme_distance'),\ heb_maj_sky_distance=fields.get('heb_maj_sky_distance'),\ heb_maj_rando_distance=fields.get('heb_maj_rando_distance'),\ heb_maj_piscine_distance...
def insertHebergementMaj(self): """ ajoute les infos de mise à jour de l'hébergement par le proprio table habergement_maj met dans table hebergement le champ heb_maj_info_etat à 'En attente de confirmation' """ fields = self.context.REQUEST chargeFk=fields.get('heb_maj_charge_fk') hebPk=fields.get('heb_maj_hebpk') hebN...
heb_maj_taxe_montant=fields.get('heb_maj_taxe_montant', 0),\ heb_maj_forfait_montant=fields.get('heb_maj_forfait_montant', 0),\
heb_maj_taxe_montant=fields.get('heb_maj_taxe_montant'),\ heb_maj_forfait_montant=fields.get('heb_maj_forfait_montant'),\
def insertHebergementMaj(self): """ ajoute les infos de mise à jour de l'hébergement par le proprio table habergement_maj met dans table hebergement le champ heb_maj_info_etat à 'En attente de confirmation' """ fields = self.context.REQUEST chargeFk=fields.get('heb_maj_charge_fk') hebPk=fields.get('heb_maj_hebpk') hebN...
heb_maj_gare_distance=fields.get('heb_maj_gare_distance', 0),\ heb_maj_restaurant_distance=fields.get('heb_maj_restaurant_distance', 0),\ heb_maj_commerce_distance=fields.get('heb_maj_commerce_distance', 0),\
heb_maj_gare_distance=fields.get('heb_maj_gare_distance'),\ heb_maj_restaurant_distance=fields.get('heb_maj_restaurant_distance'),\ heb_maj_commerce_distance=fields.get('heb_maj_commerce_distance'),\
def insertHebergementMaj(self): """ ajoute les infos de mise à jour de l'hébergement par le proprio table habergement_maj met dans table hebergement le champ heb_maj_info_etat à 'En attente de confirmation' """ fields = self.context.REQUEST chargeFk=fields.get('heb_maj_charge_fk') hebPk=fields.get('heb_maj_hebpk') hebN...
def insertTypeTableHoteOfHebergementMaj(self):
def insertTypeTableHoteOfHebergementMaj(self, hebPk, tableHotePk):
def insertTypeTableHoteOfHebergementMaj(self): """ ajoute les infos de mise à jour des tables d'hote d'un hebergement par le proprio table heb_tab_hote_maj """ fields = self.context.REQUEST hebPk=fields.get('heb_maj_hebpk') tableHotePk=fields.get('hebhot_tabhot_fk') wrapper = getSAWrapper('gites_wallons') session = wra...
fields = self.context.REQUEST hebPk=fields.get('heb_maj_hebpk') tableHotePk=fields.get('hebhot_tabhot_fk')
def insertTypeTableHoteOfHebergementMaj(self): """ ajoute les infos de mise à jour des tables d'hote d'un hebergement par le proprio table heb_tab_hote_maj """ fields = self.context.REQUEST hebPk=fields.get('heb_maj_hebpk') tableHotePk=fields.get('hebhot_tabhot_fk') wrapper = getSAWrapper('gites_wallons') session = wra...
self.insertTypeTableHoteOfHebergementMaj()
if tableHotePk: self.insertTypeTableHoteOfHebergementMaj(hebPk, tableHotePk)
def addHebergementMaj(self): """ gestion de l'ajout des données de maj d'une hebergement """ fields = self.request hebPk = fields.get('heb_maj_hebpk') hebNom = fields.get('heb_maj_nom') hebergement = self.getHebergementByHebPk(hebPk) for elem in hebergement: hebergementPk = elem.heb_pk if int(hebPk) == hebergementPk:...
heb_maj_charge_fk=chargeFk)
heb_maj_charge_fk=int(chargeFk))
def insertHebergementMaj(self): """ ajoute les infos de mise à jour de l'hébergement par le proprio table habergement_maj met dans table hebergement le champ heb_maj_info_etat à 'En attente de confirmation' """ fields = self.context.REQUEST chargeFk=fields.get('heb_maj_charge_fk') hebPk=fields.get('heb_maj_hebpk') hebN...
query = session.query(HebergementTable).join('commune')
ProprioTable = wrapper.getMapper('proprio') query = session.query(HebergementTable).join('commune').join('proprio')
def getHebergements(self): """ Return the concerned hebergements in this Town for the selected type of hebergement """ wrapper = getSAWrapper('gites_wallons') session = wrapper.session HebergementTable = wrapper.getMapper('hebergement') CommuneTable = wrapper.getMapper('commune') query = session.query(HebergementTable)...
parser.add_option("-d", "--database", dest="database", help="Database name (required unless query uses fully qualified table names)")
parser.add_option("-d", "--database", dest="database", help="Database name (required)")
def parse_options(): usage = "usage: oak-repeat-query [options]" parser = OptionParser(usage=usage) parser.add_option("-u", "--user", dest="user", default="", help="MySQL user") parser.add_option("-H", "--host", dest="host", default="localhost", help="MySQL host (default: localhost)") parser.add_option("-p", "--passwor...
parser.add_option("-e", "--execute", dest="execute_query", help="Query (UPDATE or DELETE) to execute, which contains a chunk placeholder (required)") parser.add_option("-s", "--sleep-time", dest="sleep_time", type="int", default=1, help="Number of seconds between log polling (default: 1)")
parser.add_option("-e", "--execute", dest="execute_query", help="Query to execute (required)") parser.add_option("-s", "--sleep-time", dest="sleep_time", type="int", default=0, help="Number of milliseconds to sleep between query executions (default: 0)")
def parse_options(): usage = "usage: oak-repeat-query [options]" parser = OptionParser(usage=usage) parser.add_option("-u", "--user", dest="user", default="", help="MySQL user") parser.add_option("-H", "--host", dest="host", default="localhost", help="MySQL host (default: localhost)") parser.add_option("-p", "--passwor...
verbose("Will sleep for %.2f seconds" % (options.sleep_time,)) time.sleep(options.sleep_time)
sleep_seconds = options.sleep_time/1000.0 verbose("Will sleep for %.2f seconds" % sleep_seconds) time.sleep(sleep_seconds)
def repeat_query(): start_time = time.time() num_iterations = 0 try: while True: num_affected_rows = act_query(options.execute_query) num_iterations += 1 if num_affected_rows: verbose("Affected rows: %d." % num_affected_rows) else: verbose("No rows affected") if options.max_iterations is not None: if num_iterations >...
exit_with_error("No query defined")
exit_with_error("No query defined (use --execute)") if not options.database: exit_with_error("No database specified (use --database)")
def exit_with_error(error_message): """ Notify and exit. """ print_error(error_message) exit(1)
count_columns_in_unique_key = int(row["COUNT_COLUMN_IN_INDEX"])
def get_shared_unique_key_columns(shared_unique_key_column_names_set): """ Choose a unique key, listed in the shared_unique_key_column_names_set (thus it is shared between the original and ghost table), and return the list of columns covered by the key. """ rows = get_possible_unique_key_columns(original_table_name) ...
parser.add_option("", "--terminate-on-not-found", dest="terminate_on_not_found", action="store_true", default="False", help="Terminate on first occurance where chunking did not affect any rows (default: False)")
parser.add_option("", "--terminate-on-not-found", dest="terminate_on_not_found", action="store_true", default=False, help="Terminate on first occurance where chunking did not affect any rows (default: False)")
def parse_options(): parser = OptionParser() parser.add_option("-u", "--user", dest="user", default="", help="MySQL user") parser.add_option("-H", "--host", dest="host", default="localhost", help="MySQL host (default: localhost)") parser.add_option("-p", "--password", dest="password", default="", help="MySQL password")...
if options.start_with is not None:
if options.end_with is not None:
def get_unique_key_range(): """ Return the first and last unique key values in the table """ # First (lowest) unique key values: if options.start_with is not None: if unique_key_type == "integer" and count_columns_in_unique_key == 1: query = "SELECT %d INTO %s" % (options.start_with, get_unique_key_min_values_variables...
print >>sys.stderr, message
sys.stderr.write("-- ERROR: %s\n" % message)
def print_error(message): print >>sys.stderr, message
def get_slave_delay(): seconds_behind_master = get_slave_delay_seconds() if options.error_if_more_than_seconds is None: print seconds_behind_master elif seconds_behind_master is None or seconds_behind_master > options.error_if_more_than_seconds: exit_with_error(seconds_behind_master) else: print seconds_behind_master
def get_slave_lag(): try: seconds_behind_master = get_slave_delay_seconds() if options.error_if_more_than_seconds is None: print seconds_behind_master elif seconds_behind_master is None or seconds_behind_master > options.error_if_more_than_seconds: exit_with_error(seconds_behind_master) else: print seconds_behind_maste...
def get_slave_delay(): seconds_behind_master = get_slave_delay_seconds() if options.error_if_more_than_seconds is None: print seconds_behind_master elif seconds_behind_master is None or seconds_behind_master > options.error_if_more_than_seconds: exit_with_error(seconds_behind_master) else: print seconds_behind_master
get_slave_delay()
get_slave_lag()
def exit_with_error(error_message): """ Notify and exit. """ print_error(error_message) exit(1)
while (num_succesive_non_improvements < max_succesive_non_improvements) and (innodb_buffer_pool_pages_dirty > 0):
while (num_succesive_non_improvements < max_succesive_non_improvements) and (min_innodb_buffer_pool_pages_dirty > 0):
def prepare_shutdown(): if get_slave_open_temp_tables() > 0 and not slave_is_running(): exit_with_error("Slave_open_temp_tables detected though slave is not running; this tool will not start the slave, since it's not it's job.") if slave_is_running(): while True: stop_slave() slave_open_temp_tables = get_slave_open_tem...
verbose("%s range (%s), (%s), %s" % (description, ",".join(unique_key_range_start_values), ",".join(unique_key_range_end_values), get_progress_and_eta_presentation(elapsed_times, elapsed_time, ratio_complete)))
verbose("%s range (%s), (%s), %s" % (description, ",".join("%s" % val for val in unique_key_range_start_values), ",".join(unique_key_range_end_values), get_progress_and_eta_presentation(elapsed_times, elapsed_time, ratio_complete)))
def act_data_pass(first_data_pass_query, rest_data_pass_query, description): # Is there any range to work with, at all? if not range_exists: return query = """ SELECT %s INTO %s """ % (get_unique_key_min_values_variables(), get_unique_key_range_start_variables()) act_query(query) start_time = time.time() elapsed_time...
self.world_pts_init = self.world_pts
print 'Start receiving input from flydra. Publishing messages to \'pose estimation\'...' self.world_pts_prev = self.world_pts
def callback(self, super_packet): packet = super_packet.packets[0] # super_packet legacy nobjs = len(packet.objects) self.world_pts = array([[obj.position.x, obj.position.y, obj.position.z] for obj in packet.objects]).T
R, T, err = rigit_nn(self.world_pts_init, self.world_pts) self.pub.publish(R.flatten().tolist(), T.tolist())
dR, dT, err = rigit_nn(self.world_pts_prev, self.world_pts) self.R = dot(dR, self.R) self.T = dot(dR, self.T) + dT self.world_pts_prev = self.world_pts self.pub.publish(self.R.flatten().tolist(), self.T.tolist())
def run(self): loop_rate = rospy.Rate(self.max_freq) while not rospy.is_shutdown(): if self.is_initialized: R, T, err = rigit_nn(self.world_pts_init, self.world_pts) self.pub.publish(R.flatten().tolist(), T.tolist())
ACTIVITY_TIMEOUT = 2592000
ACTIVITY_TIMEOUT = 31536000
def handler(self, context): import HaloRadio.Util as Util
now = time.mktime(datetime.datetime.now().timetuple()) if time.mktime(last_seen.timetuple()) > now -ACTIVITY_TIMEOUT: entity={} entity['username']=u.name entity['userlink']="%s?action=userInfo&id=%s" % ( self.config['general.cgi_url'], u.id ) entity['seen_on']=u.LastSeen() users.append(entity)
if last_seen!=None: now = time.mktime(datetime.datetime.now().timetuple()) if time.mktime(last_seen.timetuple()) > now -ACTIVITY_TIMEOUT: entity={} entity['username']=u.name entity['userlink']="%s?action=userInfo&id=%s" % ( self.config['general.cgi_url'], u.id ) entity['seen_on']=u.LastSeen() users.append(entity)
def handler(self, context): import HaloRadio.Util as Util
current_version=5
current_version=6
def check_dbversion(): cfg = Config.Config() current_version=5 try: dbversion=cfg.GetConfigItem("dbversion") except: print "WARNING: dbversion tag not found." print " : Check that your DB structure is up to date." return 0 dbversion=int(dbversion) if dbversion < current_version: print "WARNING: dbversion tag i...
track = 0
track = "0"
def update_db(slow, verbose=0): from mutagen import File cfg = Config.Config() timenow = time.time() #print "timenow %s" % timenow if slow: #filestr = "find %s -follow -type f -name \"*.mp3\" " % ( arc_root ) filestr = "find %s -follow -type f " % ( arc_root ) else: try: lastupdatesecs=float(cfg.GetConfigItem("las...
assert 'value' in data, ( 'Invalid server response; no value: %s' % body)
if 'value' not in data: data['value'] = None
def _request(self, url, data=None, method=None): """Send an HTTP request to the remote server.
self.assertEquals(str(i), elem.get_attribute("index"))
self.assertEquals(i, elem.get_attribute("index"))
def testGetImplicitAttribute(self): self._loadPage("nestedElements") elems = self.driver.find_elements_by_xpath("//option") self.assert_(len(elems) >= 3) for i, elem in enumerate(elems[:3]): self.assertEquals(str(i), elem.get_attribute("index"))
return float(self.get_string(verb, args))
return self.get_string(verb, args)
def get_number(self, verb, args): return float(self.get_string(verb, args))
return [float(n) for n in self.get_string_array(verb, args)]
return self.get_string_array(verb, args)
def get_number_array(self, verb, args): return [float(n) for n in self.get_string_array(verb, args)]
def start(self): result = self.get_string("getNewBrowserSession", [self.browserStartCommand, self.browserURL, self.extensionJs])
def start(self, browserConfigurationOptions=None): start_args = [self.browserStartCommand, self.browserURL, self.extensionJs] if browserConfigurationOptions: start_args.append(browserConfigurationOptions) result = self.get_string("getNewBrowserSession", start_args)
def start(self): result = self.get_string("getNewBrowserSession", [self.browserStartCommand, self.browserURL, self.extensionJs]) try: self.sessionId = result except ValueError: raise Exception, result
any IOError, else returns True."""
any IOError, else returns True. Use full paths in your filename."""
def get_screenshot_as_file(self, filename): """Gets the screenshot of the current window. Returns False if there is any IOError, else returns True.""" png = self._execute(Command.SCREENSHOT)['value'] f = None try: f = open(filename, 'w') f.write(base64.decode(png)) f.close() except IOError: return False
f = None
def get_screenshot_as_file(self, filename): """Gets the screenshot of the current window. Returns False if there is any IOError, else returns True.""" png = self._execute(Command.SCREENSHOT)['value'] f = None try: f = open(filename, 'w') f.write(base64.decode(png)) f.close() except IOError: return False
f.write(base64.decode(png))
f.write(base64.decodestring(png))
def get_screenshot_as_file(self, filename): """Gets the screenshot of the current window. Returns False if there is any IOError, else returns True.""" png = self._execute(Command.SCREENSHOT)['value'] f = None try: f = open(filename, 'w') f.write(base64.decode(png)) f.close() except IOError: return False
RemoteImplicitWaitTest.driver = webdriver.connect('firefox')
RemoteImplicitWaitTest.driver = webdriver.connect("remote", browser_name="firefox", platform="ANY")
def setup_module(module): webserver = SimpleWebServer() webserver.start() RemoteImplicitWaitTest.webserver = webserver RemoteImplicitWaitTest.driver = webdriver.connect('firefox')
except WindowsError:
except OSError.WindowsError:
def _find_chrome_in_registry(): from _winreg import OpenKey, QueryValue, HKEY_CURRENT_USER path = r"Software\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome" try: key = OpenKey(HKEY_CURRENT_USER, path) install_dir = QueryValue(key, "InstallLocation") except WindowsError: return "" return join(install_dir, "c...
return join(install_dir, "chrome.exe")
return os.path.join(install_dir, "chrome.exe")
def _find_chrome_in_registry(): from _winreg import OpenKey, QueryValue, HKEY_CURRENT_USER path = r"Software\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome" try: key = OpenKey(HKEY_CURRENT_USER, path) install_dir = QueryValue(key, "InstallLocation") except WindowsError: return "" return join(install_dir, "c...
import sys
def _is_win7(): import sys return sys.getwindowsversion()[0] == 6
appdata = environ["LOCALAPPDATA"]
appdata = os.environ["LOCALAPPDATA"]
def _default_windows_location(): if _is_win7(): appdata = environ["LOCALAPPDATA"] else: home = expanduser("~") appdata = join(home, "Local Settings", "Application Data") return join(appdata, "Google", "Chrome", "Application", "chrome.exe")
home = expanduser("~") appdata = join(home, "Local Settings", "Application Data") return join(appdata, "Google", "Chrome", "Application", "chrome.exe")
home = os.path.expanduser("~") appdata = os.path.join(home, "Local Settings", "Application Data") return os.path.join(appdata, "Google", "Chrome", "Application", "chrome.exe")
def _default_windows_location(): if _is_win7(): appdata = environ["LOCALAPPDATA"] else: home = expanduser("~") appdata = join(home, "Local Settings", "Application Data") return join(appdata, "Google", "Chrome", "Application", "chrome.exe")
locations = ["/usr/bin/google-chrome","/usr/bin/chromium","/usr/bin/chromium-browser"]
locations = [ "/usr/bin/google-chrome", "/usr/bin/chromium", "/usr/bin/chromium-browser", ]
def _linux_chrome(): locations = ["/usr/bin/google-chrome","/usr/bin/chromium","/usr/bin/chromium-browser"] return _start_cmd(locations)
locations.append(join("/Users/", getpass.getuser(), "Applications", "Google Chrome.app", "Contents", "MacOS", "Google Chrome"))
locations.append(os.path.join("/Users/", getpass.getuser(), "Applications", "Google Chrome.app", "Contents", "MacOS", "Google Chrome"))
def _mac_chrome(): locations = ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"] import getpass locations.append(join("/Users/", getpass.getuser(), "Applications", "Google Chrome.app", "Contents", "MacOS", "Google Chrome")) return _start_cmd(locations)
if exists(cmd_path): cmd = cmd_path if cmd=="": raise RuntimeError("Unable to find browser")
if os.path.exists(cmd_path): cmd = cmd_path if cmd == "": raise RuntimeError("Unable to find browser")
def _start_cmd(locations): cmd = "" for cmd_path in locations: if exists(cmd_path): cmd = cmd_path if cmd=="": raise RuntimeError("Unable to find browser") return cmd
"win32" : _windows_chrome, "darwin" : _mac_chrome, "linux2" : _linux_chrome
"win32": _windows_chrome, "darwin": _mac_chrome, "linux2": _linux_chrome,
def _start_cmd(locations): cmd = "" for cmd_path in locations: if exists(cmd_path): cmd = cmd_path if cmd=="": raise RuntimeError("Unable to find browser") return cmd
return _BINARY[platform]()
return _BINARY[sys.platform]()
def chrome_exe(): return _BINARY[platform]()
extension_dir = join(dirname(abspath(__file__)), "chrome-extension.zip")
extension_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "chrome-extension.zip")
def create_extension_dir(): extension_dir = _copy_zipped_extension("chrome-extension.zip") if extension_dir: return extension_dir extension_dir = join(dirname(abspath(__file__)), "chrome-extension.zip") extension_dir = _copy_zipped_extension(extension_dir) if extension_dir: return extension_dir path = mkdtemp() # FI...
path = mkdtemp()
path = tempfile.mkdtemp()
def create_extension_dir(): extension_dir = _copy_zipped_extension("chrome-extension.zip") if extension_dir: return extension_dir extension_dir = join(dirname(abspath(__file__)), "chrome-extension.zip") extension_dir = _copy_zipped_extension(extension_dir) if extension_dir: return extension_dir path = mkdtemp() # FI...
extdir = join(dirname(abspath(__file__)), "extension") if not isdir(extdir): extdir = join(dirname(dirname(abspath(__file__))), "extension") assert isdir(extdir), "can't find extension"
extdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "extension") if not os.path.isdir(extdir): extdir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "extension") assert os.path.isdir(extdir), "can't find extension"
def create_extension_dir(): extension_dir = _copy_zipped_extension("chrome-extension.zip") if extension_dir: return extension_dir extension_dir = join(dirname(abspath(__file__)), "chrome-extension.zip") extension_dir = _copy_zipped_extension(extension_dir) if extension_dir: return extension_dir path = mkdtemp() # FI...
path = mkdtemp()
path = tempfile.mkdtemp()
def create_profile_dir(): path = mkdtemp() return path
PORT = 33292 def run_chrome(extension_dir, profile_dir, port,untrusted_certificates, custom_args):
PORT = 0 def on_error(func, path, exc_info): import stat if not os.access(path, os.W_OK): os.chmod(path, stat.S_IWUSR) func(path) else: pass def run_chrome(extension_dir, profile_dir, port, untrusted_certificates, custom_args):
def create_profile_dir(): path = mkdtemp() return path
custom_args] return Popen(command)
custom_args, ] return subprocess.Popen(command)
def run_chrome(extension_dir, profile_dir, port,untrusted_certificates, custom_args): command = [ chrome_exe(), "--load-extension=%s" % extension_dir, "--user-data-dir=%s" % profile_dir, "--activate-on-launch", "--disable-hang-monitor", "--homepage=about:blank", "--no-first-run", "--disable-popup-blocking", "--disable-...
server = HTTPServer(("", 0), RequestHandler) server.command_queue = Queue() server.result_queue = Queue() t = Thread(target=server.serve_forever)
server = BaseHTTPServer.HTTPServer(("", 0), RequestHandler) server.command_queue = Queue.Queue() server.result_queue = Queue.Queue() t = threading.Thread(target=server.serve_forever)
def run_server(timeout=10): server = HTTPServer(("", 0), RequestHandler) server.command_queue = Queue() server.result_queue = Queue() t = Thread(target=server.serve_forever) t.daemon = True t.start() start = time() while time() - start < timeout: try: urlopen("http://localhost:%s" % server.server_port) break except IO...
start = time() while time() - start < timeout:
start = time.time() while time.time() - start < timeout:
def run_server(timeout=10): server = HTTPServer(("", 0), RequestHandler) server.command_queue = Queue() server.result_queue = Queue() t = Thread(target=server.serve_forever) t.daemon = True t.start() start = time() while time() - start < timeout: try: urlopen("http://localhost:%s" % server.server_port) break except IO...
urlopen("http://localhost:%s" % server.server_port)
urllib.urlopen("http://localhost:%s" % server.server_port)
def run_server(timeout=10): server = HTTPServer(("", 0), RequestHandler) server.command_queue = Queue() server.result_queue = Queue() t = Thread(target=server.serve_forever) t.daemon = True t.start() start = time() while time() - start < timeout: try: urlopen("http://localhost:%s" % server.server_port) break except IO...
sleep(0.1)
time.sleep(0.1)
def run_server(timeout=10): server = HTTPServer(("", 0), RequestHandler) server.command_queue = Queue() server.result_queue = Queue() t = Thread(target=server.serve_forever) t.daemon = True t.start() start = time() while time() - start < timeout: try: urlopen("http://localhost:%s" % server.server_port) break except IO...
self._profile_dir = create_profile_dir() if self._profile_dir else self._profile_dir
self._profile_dir = create_profile_dir() if self._profile_dir is None else self._profile_dir
def start(self): self._extension_dir = create_extension_dir() self._profile_dir = create_profile_dir() if self._profile_dir else self._profile_dir self._server = run_server() self._chrome = run_chrome(self._extension_dir, self._profile_dir, self._server.server_port, self._untrusted_certificates, self._custom_args)
if self._chrome: try: self._chrome.kill() self._chrome.wait() self._chrome = None except AttributeError: pass
try: os.kill(self._chrome.pid, signal.SIGTERM) except AttributeError: if platform.version() == "Windows": import ctypes PROCESS_TERMINATE = 1 handle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, False, self._chrome.pid) ctypes.windll.kernel32.TerminateProcess(handle, -1) ctypes.windll.kernel32.CloseHandle(han...
def stop(self): if self._chrome: try: self._chrome.kill() self._chrome.wait() self._chrome = None except AttributeError: # POpen.kill is a python 2.6 API... pass
print path if not path: continue for i in xrange(5): if os.path.exists(path): shutil.rmtree(path) if os.path.exists(path): return "Couldn't delete profile. Please try manually."
try: shutil.rmtree(path, ignore_errors=False, onerror=on_error) except OSError: pass
def stop(self): if self._chrome: try: self._chrome.kill() self._chrome.wait() self._chrome = None except AttributeError: # POpen.kill is a python 2.6 API... pass
result = response.reason
def do_command(self, verb, args): conn = httplib.HTTPConnection(self.host, self.port) body = u'cmd=' + urllib.quote_plus(unicode(verb).encode('utf-8')) for i in range(len(args)): body += '&' + unicode(i+1) + '=' + urllib.quote_plus(unicode(args[i]).encode('utf-8')) if (None != self.sessionId): body += "&sessionId=" + u...