rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
titles = {} for col in self.columnDefs: titles[col['columnId']] = col['columnTitle']
def htmlValue(self, REQUEST): """ return from REQUEST, this field's value in html. """
for akey in adict.keys(): if akey != 'orderindex_': res = "%s\n<td>%s</td>" % (res, cgi.escape(adict[akey]))
for col in self.columnDefs: akey = col['columnId'] res = "%s\n<td>%s</td>" % (res, cgi.escape(adict[akey]))
def htmlValue(self, REQUEST): """ return from REQUEST, this field's value in html. """
self.login_page += "&action=submit&returnto=Special:Userlogin"
self.login_page += "&action=submit"
def __init__(self, username, password, host, basename, https=False, port=None, domain=None, httpauth_username=None, httpauth_password=None, logger = None, # Not actually needed, just here for compatibility name=None, cookie_str=None, dirname=None ):
"wpLoginattempt":"Identification", "wpRemember":"1"}
"wpRemember":"1", "wpLoginattempt":"Anmelden"}
def getCookieString(self): """ Gets user's cookie string. It will then have to be passed to an Article. """
headers = {"Content-type": "application/x-www-form-urlencoded", "User-agent" : "WikipediaFS"} conn = ExtendedHTTPConnection(self.host, self.port, self.https) if self.httpauth_username and self.httpauth_password: conn.http_auth(self.httpauth_username, self.httpauth_password)
def getCookieString(self): """ Gets user's cookie string. It will then have to be passed to an Article. """
cookie_list = []
printlog(self.logger, "debug", "URL: %s, response status: %d, text: %s" % (self.login_page, response.status, response.read()))
def getCookieString(self): """ Gets user's cookie string. It will then have to be passed to an Article. """
"Could not log in with username %s" % self.username)
"Could not log in with username %s: %s" % self.username)
def getCookieString(self): """ Gets user's cookie string. It will then have to be passed to an Article. """
self.output = dict(path=urllib.pathname2url(outFile),type=profile['output_mime_type'])
self.output = dict(path = outFile, type = profile['output_mime_type'])
def __init__(self, input, output, profile, options, **kwargs): dict.__init__(self) self.input = input self.output = output self.options = options self.profile = profile self.defer = Deferred() for key,value in kwargs.items(): self[key] = value
return [item for item in db_items if self.CURR_SCRIPT in item['name'] or self.CURR_SCRIPT in item['description']]
return [item for item in db_items if self.CURR_SCRIPT.lower() in item['name'].lower() or self.CURR_SCRIPT.lower() in item['description'].lower()]
def search(self): """ Search github vim-scripts, return array.
e.set_material_markers([8, 2]) e.set_permittivity_array([4, 3.1]) e.set_charge_density_array([4, 3.1]) e.set_boundary_markers_value([1, 3]) e.set_boundary_values([1, 5]) e.set_boundary_markers_derivative([2, 4]) e.set_boundary_derivatives([1, 5])
e.set_material_markers([0]) e.set_permittivity_array([1]) e.set_charge_density_array([1]) e.set_boundary_markers_value([4]) e.set_boundary_values([0]) e.set_boundary_markers_derivative([1, 2, 3]) e.set_boundary_derivatives([0, 0, 0])
def main(): e = Electrostatics() e.set_mesh_str("\na = 1.0 # size of the mesh\nb = sqrt(2)/2\n\nvertices =\n{\n { 0, -a }, # vertex 0\n { a, -a }, # vertex 1\n { -a, 0 }, # vertex 2\n { 0, 0 }, # vertex 3\n { a, 0 }, # vertex 4\n { -a, a }, # vertex 5\n { 0, a }, # vertex 6\n { a*b, a*b...
def xLabel(parent,label): return wx.StaticText(parent,label=label,style=wx.ALIGN_BOTTOM)
pvname = '13XRM:m2.VAL'
def xLabel(parent,label): return wx.StaticText(parent,label=label,style=wx.ALIGN_BOTTOM)
def xTitle(parent,label,fontsize=13,color='Blue'): u = wx.StaticText(parent,label=label,style=wx.ALIGN_BOTTOM) u.SetFont(wx.Font(fontsize,wx.SWISS,wx.NORMAL,wx.BOLD,False)) u.SetForegroundColour(color) return u class MotorDetailFrame(wx.Frame): """ Detailed Motor Setup Frame""" __motor_fields = ('set', 'low_limit','hi...
mypv = epics.PV(pvname)
def xTitle(parent,label,fontsize=13,color='Blue'): u = wx.StaticText(parent,label=label,style=wx.ALIGN_BOTTOM) u.SetFont(wx.Font(fontsize,wx.SWISS,wx.NORMAL,wx.BOLD,False)) u.SetForegroundColour(color) return u
nrow = nrow + 1 ds.Add(xLabel(dp,"Low Limit"), (nrow,0), (1,1), _textstyle,_textpadding) ds.Add(self.motor_ctrl(dp,'low_limit'), (nrow,1), (1,1), wx.ALIGN_CENTER) ds.Add(self.motor_ctrl(dp,'dial_low_limit'), (nrow,2), (1,1), wx.ALIGN_CENTER) twk_sizer = wx.BoxSizer(wx.HORIZONTAL) twk_panel = wx.Pa...
def wait(timeout=6): t0 = time.time() while time.time() - t0 < timeout: time.sleep(1.e-3) epics.poll()
def __init__(self, parent=None, motor=None): wx.Frame.__init__(self, parent, wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE,size=(500,775) ) self.SetFont(wx.Font(11,wx.SWISS,wx.NORMAL,wx.BOLD,False))
able_btns = pvEnumButtons(dp, pv=self.motor.get_pv('enabled'), orientation = wx.VERTICAL, size=(110,-1)) ds.Add(able_btns, (nrow-1,3), (2,1), wx.ALIGN_CENTER) stop_btns = pvEnumButtons(dp, pv=self.motor.get_pv('stop_go'), orientation = wx.VERTICAL, size=(110,-1)) ds.Add(stop_btns, (2,4), (4,1...
print 'Created PV = ', mypv def CB1(pvname=None, value=None, char_value=None, **kw): print 'CB1 PV Changed! ', pvname, value, char_value
def __init__(self, parent=None, motor=None): wx.Frame.__init__(self, parent, wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE,size=(500,775) ) self.SetFont(wx.Font(11,wx.SWISS,wx.NORMAL,wx.BOLD,False))
ds.Add(xLabel(dp, 'Freeze Offset: '), (0,2),(1,1), _textstyle,_textpadding) ds.Add(pvEnumChoice(dp, pv=self.motor.get_pv('freeze_offset'), size=(110,-1)), (0,3), (1,1), wx.ALIGN_CENTER) ds.Add(xLabel(dp, 'Offset Value: '), (1,2),(1,1), _textstyle,_textpadding) ds.Add(self.motor_ctrl(dp,'offset'), (1,3), (1,1), wx.ALI...
def CB2(pvname=None, value=None, char_value=None, **kw): print 'CB2 ! ', pvname, value, char_value
def __init__(self, parent=None, motor=None): wx.Frame.__init__(self, parent, wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE,size=(500,775) ) self.SetFont(wx.Font(11,wx.SWISS,wx.NORMAL,wx.BOLD,False))
set_sizer(dp,ds) sizer.Add(dp,0) sizer.Add((5,5), 0) sizer.Add(wx.StaticLine(panel,size=(100,2)), 0, wx.EXPAND) sizer.Add((5,5), 0) ds = wx.GridBagSizer(6, 3) dp = wx.Panel(panel) nrow = 0
mypv.add_callback(CB1)
def __init__(self, parent=None, motor=None): wx.Frame.__init__(self, parent, wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE,size=(500,775) ) self.SetFont(wx.Font(11,wx.SWISS,wx.NORMAL,wx.BOLD,False))
ds.Add(xTitle(dp,"Dynamics"), (nrow,0), (1,1), _textstyle,_textpadding) ds.Add(xLabel(dp,"Normal" ), (nrow,1), (1,1), wx.ALIGN_CENTER) ds.Add(xLabel(dp,"Backlash" ), (nrow,2), (1,1), wx.ALIGN_CENTER)
print 'Added a callback. Now wait for changes'
def __init__(self, parent=None, motor=None): wx.Frame.__init__(self, parent, wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE,size=(500,775) ) self.SetFont(wx.Font(11,wx.SWISS,wx.NORMAL,wx.BOLD,False))
nrow = nrow + 1 ds.Add(xLabel(dp,"Max Speed"), (nrow,0), (1,1), _textstyle,_textpadding) ds.Add(self.motor_ctrl(dp,'max_speed'), (nrow,1), (1,1), wx.ALIGN_CENTER)
print 'ready'
def __init__(self, parent=None, motor=None): wx.Frame.__init__(self, parent, wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE,size=(500,775) ) self.SetFont(wx.Font(11,wx.SWISS,wx.NORMAL,wx.BOLD,False))
nrow = nrow + 1 ds.Add(xLabel(dp,"Speed"), (nrow,0), (1,1), _textstyle,_textpadding) ds.Add(self.motor_ctrl(dp,'slew_speed'), (nrow,1), (1,1), wx.ALIGN_CENTER) ds.Add(self.motor_ctrl(dp,'back_speed'), (nrow,2), (1,1), wx.ALIGN_CENTER)
wait(10) print 'now, add another: ' mypv.add_callback(CB2)
def __init__(self, parent=None, motor=None): wx.Frame.__init__(self, parent, wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE,size=(500,775) ) self.SetFont(wx.Font(11,wx.SWISS,wx.NORMAL,wx.BOLD,False))
nrow = nrow + 1 ds.Add(xLabel(dp,"Base Speed"), (nrow,0), (1,1), _textstyle,_textpadding) ds.Add(self.motor_ctrl(dp,'base_speed'), (nrow,1), (1,1), wx.ALIGN_CENTER) nrow = nrow + 1 ds.Add(xLabel(dp,"Accel (s)"), (nrow,0), (1,1), _textstyle,_textpadding) ds.Add(self.motor_ctrl(dp,'acceler...
wait(10)
def __init__(self, parent=None, motor=None): wx.Frame.__init__(self, parent, wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE,size=(500,775) ) self.SetFont(wx.Font(11,wx.SWISS,wx.NORMAL,wx.BOLD,False))
def motor_text(self,panel,attr): return pvText(panel, size=(100,-1), style=wx.ALIGN_RIGHT|wx.CENTER, as_string=True, pv=self.motor.get_pv(attr))
def motor_text(self,panel,attr): return pvText(panel, size=(100,-1), style=wx.ALIGN_RIGHT|wx.CENTER, as_string=True, pv=self.motor.get_pv(attr))
def motor_textctrl(self,panel,attr,size=(100,-1)): return pvTextCtrl(panel, size=size, pv=self.motor.get_pv(attr)) def onLimitChange(self,pv=None,attr=None,**kw): lim_val = self.motor.get_field(attr) if 'low_limit' == attr: self.drives[0].SetMin(lim_val) elif 'high_limit' == attr: self.drives[0].Set...
def motor_textctrl(self,panel,attr,size=(100,-1)): return pvTextCtrl(panel, size=size, # style=wx.ALIGN_RIGHT, pv=self.motor.get_pv(attr))
elif isinstance(pv, (string, unicode)):
elif isinstance(pv, (str, unicode)):
def set_pv(self, pv=None): if isinstance(pv, epics.PV): self.pv = pv elif isinstance(pv, (string, unicode)): self.pv = epics.PV(pv) self.pv.connect() if self.pv is None: return
elif isinstance(pv, (string, unicode)):
elif isinstance(pv, (str, unicode)):
def set_pv(self, pv=None): # print 'FloatCtrl: SET PV ', pvname, type(pvname), isinstance(pvname, epics.PV) if isinstance(pv, epics.PV): self.pv = pv elif isinstance(pv, (string, unicode)): self.pv = epics.PV(pv) if self.pv is None: return self.pv.get() self.pv.get_ctrlvars() # be sure to set precision before value!! o...
dc = wx.PaintDC(self) dc.DrawBitmap(bmp, diffx, diffy, useMask=True)
try: dc = wx.PaintDC(self) except: pass if dc is not None: dc.DrawBitmap(bmp, diffx, diffy, useMask=True)
def DrawImage(self, dc=None, size=None): if not hasattr(self,'image') or self.image is None: return if size is None: size = self.GetSize() wwidth,wheight = size image = self.image bmp = None if image.IsOk(): iwidth = image.GetWidth() iheight = image.GetHeight() else: bmp = wx.ArtProvider.GetBitmap(wx.ART_MISSING_IMAGE,...
d.show()
def RefreshImage(self): d = debugtime() if self.get('ArrayData') is None: return im_mode = 'L' im_size = (self.arrsize[0], self.arrsize[1]) if self.colormode == 2: im_mode = 'RGB' im_size = [self.arrsize[1], self.arrsize[2]] d.add('know image size/type') rawdata = self.get('ArrayData') d.add('have rawdata')
_fields_ = list(_STAT_SEV) +[_UNITS] + _gen_ctrl_lims(t=long_t) _fields_.extend([('value', long_t)])
_fields_ = list(_STAT_SEV) +[_UNITS] + _gen_ctrl_lims(t=int_t) _fields_.extend([('value', int_t)])
def _gen_ctrl_lims(t=short_t): return [(s, t) for s in ctrl_limits]
LONG: long_t,
LONG: int_t,
def _gen_ctrl_lims(t=short_t): return [(s, t) for s in ctrl_limits]
('chid', long_t),
('chid', int_t),
def Cast(args): """returns pointer to arg type for casting """ count, ftype = args.count, args.type if ftype == STRING: count = MAX_STRING_SIZE if ftype not in Map: ftype = double_t return ctypes.cast(args.raw_dbr, ctypes.POINTER(count*Map[ftype]))
('status', long_t)]
('status', int_t)]
def Cast(args): """returns pointer to arg type for casting """ count, ftype = args.count, args.type if ftype == STRING: count = MAX_STRING_SIZE if ftype not in Map: ftype = double_t return ctypes.cast(args.raw_dbr, ctypes.POINTER(count*Map[ftype]))
_fields_ = [('chid', long_t), ('op', long_t)]
_fields_ = [('chid',int_t), ('op', long_t)]
def Cast(args): """returns pointer to arg type for casting """ count, ftype = args.count, args.type if ftype == STRING: count = MAX_STRING_SIZE if ftype not in Map: ftype = double_t return ctypes.cast(args.raw_dbr, ctypes.POINTER(count*Map[ftype]))
value = _unpack(value, nelem, ftype=args.type)
value = _unpack(value, count=nelem, ftype=args.type)
def _onGetEvent(args): """Internal Event Handler for get events: not intended for use""" value = dbr.cast_args(args).contents # print(" onGet Event: ", args.chid, type(args.chid)) # chid = dbr.chid_t(args.chid) pvname = name(args.chid) kwd = {'ftype':args.type, 'count':args.count, 'chid':args.chid, 'pvname': pvname, 's...
def _unpack(data, count, ftype=dbr.INT, as_numpy=True):
def _unpack(data, count=None, chid=None, ftype=None, as_numpy=True):
def _unpack(data, count, ftype=dbr.INT, as_numpy=True): """unpack raw data returned from an array get or subscription callback""" def unpack_simple(data, count, ntype, use_numpy): if count == 1 and ntype != dbr.STRING: return data[0] if ntype == dbr.STRING: out = strjoin('', data).rstrip() if '\x00' in out: out = out[...
def get(chid, ftype=None, as_string=False, as_numpy=True):
def get(chid, ftype=None, as_string=False, count=None, as_numpy=True):
def get(chid, ftype=None, as_string=False, as_numpy=True): """return the current value for a Channel. Options are ftype field type to use (native type is default) as_string flag(True/False) to get a string representation of the value returned. This is not nearly as featured as for a PV -- see pv.py for more d...
count = element_count(chid)
if count is None: count = element_count(chid) else: count = min(count, element_count(chid))
def get(chid, ftype=None, as_string=False, as_numpy=True): """return the current value for a Channel. Options are ftype field type to use (native type is default) as_string flag(True/False) to get a string representation of the value returned. This is not nearly as featured as for a PV -- see pv.py for more d...
val = _unpack(data, nelem, ftype=ftype, as_numpy=as_numpy)
val = _unpack(data, count=nelem, ftype=ftype, as_numpy=as_numpy)
def get(chid, ftype=None, as_string=False, as_numpy=True): """return the current value for a Channel. Options are ftype field type to use (native type is default) as_string flag(True/False) to get a string representation of the value returned. This is not nearly as featured as for a PV -- see pv.py for more d...
self.connion_timeout = timeout
self.connection_timeout = timeout
def connect(self, timeout=None, force=True): "check that a PV is connected, forcing a connection if needed" if not self.connected: if timeout is not None: self.connion_timeout = timeout ca.connect_channel(self.chid, timeout=self.connection_timeout, force=force) self.poll() self._conn_started = True return self.connecte...
if dial: drv,rbv,lims = self._dial_params if step or raw: drv,rbv,lims = self._raw_params if (relative): val = val + self.get_field(rbv)
if dial: drv, rbv, lims = self._dial_params if step or raw: drv, rbv, lims = self._raw_params ignore_limits = True if (relative): val = val + self.get_field(rbv)
def move(self,val=None,relative=None,wait=False, timeout=3600.0, dial=False,step=False,raw=False, ignore_limits=False):
stat = self.put_field(drv,val,wait=wait,timeout=timeout)
stat = self.put_field(ifield, 1, wait=wait, timeout=timeout)
def tweak(self,dir='forward',wait=False,timeout=3600.0): """ move the motor by the tweak_val takes optional args: dir direction of motion (forward/reverse) [forward] must start with 'rev' or 'back' for a reverse tweak. wait wait for move to complete before returning (T/F) [F] timeout max t...
'CAST(year AS ' + type_name + '), week, employee, hours ' \
'CAST(year AS ' + type_name + ') AS year, week, ' \ 'employee, hours ' \
def table_query(self, context=None): type_name = FIELDS[self.year._type].sql_type(self.year)[0] return ('SELECT id, create_uid, create_date, write_uid, write_date, ' \ 'CAST(year AS ' + type_name + '), week, employee, hours ' \ 'FROM (' 'SELECT EXTRACT(WEEK FROM date) + ' \ 'EXTRACT(YEAR FROM date) * 100 + ' \ 'employe...
'CAST(year AS ' + type_name + '), month, employee, hours ' \
'CAST(year AS ' + type_name + ') AS year, month, ' \ 'employee, hours ' \
def table_query(self, context=None): type_name = FIELDS[self.year._type].sql_type(self.year)[0] return ('SELECT id, create_uid, create_date, write_uid, write_date, ' \ 'CAST(year AS ' + type_name + '), month, employee, hours ' \ 'FROM (' 'SELECT EXTRACT(MONTH FROM date) + ' \ 'EXTRACT(YEAR FROM date) * 100 + ' \ 'emplo...
self.assertRaises(Exception, test_view('timesheet'))
test_view('timesheet')
def test0005views(self): ''' Test views. ''' self.assertRaises(Exception, test_view('timesheet'))
def get_hours(self, name):
def get_hours(self, ids, name):
def get_hours(self, name): all_ids = self.search([ ('parent', 'child_of', ids), ]) # force inactive ids to be in all_ids all_ids = all_ids + ids clause = "SELECT work, sum(hours) FROM timesheet_line "\ "WHERE work IN (%s) "\ % ",".join(('%s',) * len(all_ids)) date_cond = "" args = [] if Transaction().context.get('from_...
def get_rec_name(self, name):
def get_rec_name(self, ids, name):
def get_rec_name(self, name): if not ids: return {} res = {} def _name(work): if work.parent: return _name(work.parent) + '\\' + work.name else: return work.name for work in self.browse(ids): res[work.id] = _name(work) return res
'CAST(year AS ' + type_name + '), week, employee, hours ' \
'CAST(year AS ' + type_name + ') AS year, week, ' \ 'employee, hours ' \
def table_query(self): type_name = FIELDS[self.year._type].sql_type(self.year)[0] return ('SELECT id, create_uid, create_date, write_uid, write_date, ' \ 'CAST(year AS ' + type_name + '), week, employee, hours ' \ 'FROM (' 'SELECT EXTRACT(WEEK FROM date) + ' \ 'EXTRACT(YEAR FROM date) * 100 + ' \ 'employee * 1000000 AS...
'CAST(year AS ' + type_name + '), month, employee, hours ' \
'CAST(year AS ' + type_name + ') AS year, month, ' \ 'employee, hours ' \
def table_query(self): type_name = FIELDS[self.year._type].sql_type(self.year)[0] return ('SELECT id, create_uid, create_date, write_uid, write_date, ' \ 'CAST(year AS ' + type_name + '), month, employee, hours ' \ 'FROM (' 'SELECT EXTRACT(MONTH FROM date) + ' \ 'EXTRACT(YEAR FROM date) * 100 + ' \ 'employee * 1000000 ...
<a\s+href="/etext/(?P<etext2>.*?)">
<a\s+href="/[^/]+/(?P<etext2>\d+)/?">
def _strip_tags(snippet): snippet = snippet.replace("&nbsp;", " ") snippet = snippet.replace("&quot;", "\"") snippet = snippet.replace("\r", " ") snippet = snippet.replace("\n", " ") snippet = snippet.replace("<br>", "\n") snippet = snippet.replace("<li>", "\n") return _TAG_RE.subn('', snippet)[0]
self.recent_button.set_active(page_num == self.RECENT_BUTTON)
self.recent_button.set_active(page_num == self.RECENT_PAGE)
def on_notebook_switch_page(self, notebook, page, page_num): self.app.config['ui_page'] = int(page_num)
data = data.replace('\n', ' ') if self.slurp_space: data = data.lstrip() self.para += data self.slurp_space = False
if not self.in_pre: data = data.replace('\n', ' ') if self.slurp_space: data = data.lstrip() if data: self.para += data self.slurp_space = False
def handle_data(self, data): if self.omit: return if not isinstance(data, unicode): try: data = unicode(data, self.encoding) except UnicodeError: data = unicode(data, 'latin1')
it = model.get_iter(self._active_item) entry = model[it]
pth = self._active_item self._active_item = None entry = model[model.get_iter(pth)] while model is not None and model is not self.store: pth = model.convert_path_to_child_path(pth) model = model.get_model() if model != self.store: raise RuntimeError("Programming error -- please report") it = model.get_iter(pth)
def on_menu_delete(self, widget): model = self.widget_tree.get_model() try: it = model.get_iter(self._active_item) entry = model[it] self._active_item = None
ret = []
data = []
def send_command(self, command, keys=None, opts=None): cmd = self.construct_command(command, keys=keys, opts=opts) self.send('%s\n' % cmd)
ret.append(resp['keys'])
data.extend(resp)
def send_command(self, command, keys=None, opts=None): cmd = self.construct_command(command, keys=keys, opts=opts) self.send('%s\n' % cmd)
if ret and resp['keys']['id'] == '0': return ret
if data and resp['keys']['id'] == '0': return data
def send_command(self, command, keys=None, opts=None): cmd = self.construct_command(command, keys=keys, opts=opts) self.send('%s\n' % cmd)
command = cmdlist[0]
command = None
def parse_command(self, commandstr): """ Parses a TS3 command string into command/keys/opts tuple
start = 1 len(command.split('=')) if len(command.split('=')) > 1: start = 0 command = '' for key in cmdlist[start:]: if len(key.split('|')) > 1: output = [] nkeys = key.split('|') for nkey in nkeys: nvalue = nkey.split('=') okey = nvalue[0] output.append(nvalue[1]) keys[okey] = output continue if len(key.split('='))...
for key in cmdlist: v = key.strip().split('=') if len(v) > 1: key, value = v keys[key] = self._unescape_str(value) elif v[0][0] == '-': opts.append(v[0][1:]) else: command = v[0]
def parse_command(self, commandstr): """ Parses a TS3 command string into command/keys/opts tuple
if d > 0: self._log.error('Error logging in') return False elif d == 0:
if d == 0:
def login(self, username, password): """ Login to the TS3 Server
data.extend(resp)
data.append(resp)
def send_command(self, command, keys=None, opts=None): cmd = self.construct_command(command, keys=keys, opts=opts) self.send('%s\n' % cmd)
return data
if len(data) > 1: return data else: return data[0]
def send_command(self, command, keys=None, opts=None): cmd = self.construct_command(command, keys=keys, opts=opts) self.send('%s\n' % cmd)
cstr = [] cstr.append(command)
cstr = [command]
def construct_command(self, command, keys=None, opts=None): """ Constructs a TS3 formatted command string
return translate(_(u"version ${version}", mapping=dict(version=version)))
return translate( _(u"version ${version}", mapping=dict(version=version)), context=self.request )
def versionTitle(self, version): return translate(_(u"version ${version}", mapping=dict(version=version)))
def save(self, prepared_obj, autoregister=None):
def save(self, prepared_obj, autoregister=False):
def save(self, prepared_obj, autoregister=None): """See IArchivist. """ if not prepared_obj.is_registered: if autoregister: return self.register(prepared_obj) raise ArchivistSaveError( "Saving an unregistered object is not possible. Register " "the object '%s' first. "% prepared_obj.original.object) storage = getToolB...
return self.register(prepared_obj) raise ArchivistSaveError( "Saving an unregistered object is not possible. Register " "the object '%s' first. "% prepared_obj.original.object)
self.register(prepared_obj) else: raise ArchivistSaveError( "Saving an unregistered object is not possible. Register " "the object '%s' first. "% prepared_obj.original.object)
def save(self, prepared_obj, autoregister=None): """See IArchivist. """ if not prepared_obj.is_registered: if autoregister: return self.register(prepared_obj) raise ArchivistSaveError( "Saving an unregistered object is not possible. Register " "the object '%s' first. "% prepared_obj.original.object) storage = getToolB...
options.outfile = args[2] options.indir = args[3]
options.outfile = os.path.normpath(args[2]) options.indir = os.path.normpath(args[3])
def main(argv): parser = OptionParser(usage="%prog <jobtype> <outfile> <indir> [options]") parser.add_option("-t", "--temp", help="use TEMPDIR to store the intermedite build files", metavar="TEMPDIR") parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False, help="don't print most status mess...
if (len(sys.argv) < 4):
if (len(sys.argv) < 5):
def main(): if (len(sys.argv) < 4): print "Output file not specifed!" sys.exit(1) work = os.path.normcase(os.path.normpath(sys.argv[WORKFILE])) file = os.path.normcase(os.path.normpath(sys.argv[OUTFILE])) if ( sys.argv[JOB] == "build" ): build(file, work) elif ( sys.argv[JOB] == "rebuild" ): rebuild(file, work) elif ...
hgloc = os.path.normcase(os.path.normpath(sys.argv[HGLOC]))
def main(): if (len(sys.argv) < 4): print "Output file not specifed!" sys.exit(1) work = os.path.normcase(os.path.normpath(sys.argv[WORKFILE])) file = os.path.normcase(os.path.normpath(sys.argv[OUTFILE])) if ( sys.argv[JOB] == "build" ): build(file, work) elif ( sys.argv[JOB] == "rebuild" ): rebuild(file, work) elif ...
build(file, work)
build(file, work, hgloc)
def main(): if (len(sys.argv) < 4): print "Output file not specifed!" sys.exit(1) work = os.path.normcase(os.path.normpath(sys.argv[WORKFILE])) file = os.path.normcase(os.path.normpath(sys.argv[OUTFILE])) if ( sys.argv[JOB] == "build" ): build(file, work) elif ( sys.argv[JOB] == "rebuild" ): rebuild(file, work) elif ...
rebuild(file, work)
rebuild(file, work, hgloc)
def main(): if (len(sys.argv) < 4): print "Output file not specifed!" sys.exit(1) work = os.path.normcase(os.path.normpath(sys.argv[WORKFILE])) file = os.path.normcase(os.path.normpath(sys.argv[OUTFILE])) if ( sys.argv[JOB] == "build" ): build(file, work) elif ( sys.argv[JOB] == "rebuild" ): rebuild(file, work) elif ...
def rebuild(file, work):
def rebuild(file, work, hgloc):
def rebuild(file, work): print "Rebuild...." clean(file, work) build(file, work)
build(file, work)
build(file, work, hgloc)
def rebuild(file, work): print "Rebuild...." clean(file, work) build(file, work)
def build(file, work):
def build(file, work, hgloc):
def build(file, work): print "Building..." if ( need_to_update(file, work) ): print " Writing tempfile:", work make_directory_for_output(work) temp = open(work, "wb") temp.write(get_hg_id()) temp.flush() temp.close() print " Writing output file:", file make_directory_for_output(file) out = open(file, "wb") out.write("...
if ( need_to_update(file, work) ):
if ( need_to_update(file, work, hgloc) ):
def build(file, work): print "Building..." if ( need_to_update(file, work) ): print " Writing tempfile:", work make_directory_for_output(work) temp = open(work, "wb") temp.write(get_hg_id()) temp.flush() temp.close() print " Writing output file:", file make_directory_for_output(file) out = open(file, "wb") out.write("...
temp.write(get_hg_id())
temp.write(get_hg_id(hgloc))
def build(file, work): print "Building..." if ( need_to_update(file, work) ): print " Writing tempfile:", work make_directory_for_output(work) temp = open(work, "wb") temp.write(get_hg_id()) temp.flush() temp.close() print " Writing output file:", file make_directory_for_output(file) out = open(file, "wb") out.write("...
out.write(get_hg_id())
out.write(get_hg_id(hgloc))
def build(file, work): print "Building..." if ( need_to_update(file, work) ): print " Writing tempfile:", work make_directory_for_output(work) temp = open(work, "wb") temp.write(get_hg_id()) temp.flush() temp.close() print " Writing output file:", file make_directory_for_output(file) out = open(file, "wb") out.write("...
subprocess.Popen('hg parents --template {date|date}'.split(), stdout=out).wait()
cmd = '%s parents --template {date|date}' % (hgloc) cmd = cmd.split() print cmd subprocess.Popen(cmd, stdout=out).wait()
def build(file, work): print "Building..." if ( need_to_update(file, work) ): print " Writing tempfile:", work make_directory_for_output(work) temp = open(work, "wb") temp.write(get_hg_id()) temp.flush() temp.close() print " Writing output file:", file make_directory_for_output(file) out = open(file, "wb") out.write("...
def get_hg_id():
def get_hg_id(hgloc):
def get_hg_id(): id = tempfile.TemporaryFile() subprocess.Popen("hg id -i -b -t".split(), stdout=id).wait() id.seek(0) return string.split(id.readline(), "\n")[0]
subprocess.Popen("hg id -i -b -t".split(), stdout=id).wait()
s = "%s id -i -b -t" % (hgloc) s = s.split() print s subprocess.Popen(s, stdout=id).wait()
def get_hg_id(): id = tempfile.TemporaryFile() subprocess.Popen("hg id -i -b -t".split(), stdout=id).wait() id.seek(0) return string.split(id.readline(), "\n")[0]
def need_to_update(file, work):
def need_to_update(file, work, hgloc):
def need_to_update(file, work): if ( os.path.exists(work) == True ): if ( os.path.exists(file) == True ): workfile = open(work, 'rb') if ( workfile.readline() == get_hg_id() ): return False else: print "hg id changed" else: print " ", file, "does not exist" else: print " ", work, "does not exist" return True
if ( workfile.readline() == get_hg_id() ):
if ( workfile.readline() == get_hg_id(hgloc) ):
def need_to_update(file, work): if ( os.path.exists(work) == True ): if ( os.path.exists(file) == True ): workfile = open(work, 'rb') if ( workfile.readline() == get_hg_id() ): return False else: print "hg id changed" else: print " ", file, "does not exist" else: print " ", work, "does not exist" return True
python_c_extension = Extension("google.protobuf.internal._net_proto2___python", [ "google/protobuf/pyext/python_descriptor.cc", "google/protobuf/pyext/python_protobuf.cc", "google/protobuf/pyext/python-proto2.cc", ], include_dirs = [ "../src", ".", ], libraries = [ "protobuf" ], runtime_library_dirs = [ "../src/.libs" ...
ext_module_list = [] if os.getenv("PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION", "python") == "cpp": print "Using EXPERIMENTAL C++ Implmenetation." ext_module_list.append(Extension( "google.protobuf.internal._net_proto2___python", [ "google/protobuf/pyext/python_descriptor.cc", "google/protobuf/pyext/python_protobuf.cc", ...
def MakeTestSuite(): # This is apparently needed on some systems to make sure that the tests # work even if a previous version is already installed. if 'google' in sys.modules: del sys.modules['google'] generate_proto("../src/google/protobuf/unittest.proto") generate_proto("../src/google/protobuf/unittest_custom_optio...
ext_modules = [ python_c_extension ],
ext_modules = ext_module_list,
def MakeTestSuite(): # This is apparently needed on some systems to make sure that the tests # work even if a previous version is already installed. if 'google' in sys.modules: del sys.modules['google'] generate_proto("../src/google/protobuf/unittest.proto") generate_proto("../src/google/protobuf/unittest_custom_optio...
menu_items = MenuItem.tree.filter(menu=content_object, level=0)
menu_items = MenuItem.tree.filter(menu=content_object, level=0, active=True)
def get_string_response(self, request, content_object=None, *args, **kwargs): menu_items = MenuItem.tree.filter(menu=content_object, level=0) c = RequestContext(request, {'menu_items': menu_items}) t = loader.get_template("cyclope/menu_flat_items_list.html") c['host_template'] = 'cyclope/inline_view.html' return t.rend...
menu_items = MenuItem.tree.filter(menu=content_object)
menu_items = MenuItem.tree.filter(menu=content_object, active=True)
def get_string_response(self, request, content_object=None, *args, **kwargs): menu_items = MenuItem.tree.filter(menu=content_object) c = RequestContext(request, {'menu_items': menu_items}) t = loader.get_template("cyclope/menu_flat_items_list.html") c['host_template'] = 'cyclope/inline_view.html' return t.render(c)
menu_items = MenuItem.objects.filter(menu = id_menu)
def menu_items_for_menu_json(self, request): id_menu = request.GET['q']
choices.extend([ {'object_id': item.id, 'verbose_name': item.name} for item in menu_items if item.id != id_menu_item and item not in descendants])
if not id_menu == '': menu_items = MenuItem.objects.filter(menu = id_menu) choices.extend([ {'object_id': item.id, 'verbose_name': u'%s %s' % ('---' * item.level, item.name)} for item in menu_items if item.id != id_menu_item and item not in descendants])
def menu_items_for_menu_json(self, request): id_menu = request.GET['q']
def get_absolute_url(self, view_name):
def get_instance_url(self, view_name=None):
def get_absolute_url(self, view_name): view = cyclope.core.frontend.site.get_view(self.__class__, view_name) if view.is_instance_view: return '%s/%s/%s/View/%s'\ % (self._meta.app_label, self._meta.object_name.lower(), self.slug, view_name) else: return '%s/%s/View/%s'\ % (self._meta.app_label, self._meta.object_name.l...
return self.cleaned_data
return super(CommentFormWithCaptcha, self).clean()
def clean(self):
def get_string_response(self, request, content_object=None, *args, **kwargs):
target_view = 'teaser_list' def get_string_response(self, request, content_object=None, *args, **kwargs):
def get_http_response(self, request, slug=None, *args, **kwargs): collection = Collection.objects.get(slug=slug) c = RequestContext( request, {'categories': Category.tree.filter(collection=collection, level=0), 'collection': collection }) t = loader.get_template("collections/collection_root_categories_teaser_list.html"...
'<a href="{% url category-teaser_list slug %}">'
'<a href="{% url category-'+self.target_view+' slug %}">'
def _get_categories_nested_list(self, base_category, name_field='name'): """Creates a nested list to be used with unordered_list template tag """ #TODO(nicoechaniz): see if there's a more efficient way to build this recursive template data. #TODO(nicoechaniz): only show categories which have children or content. from d...
def get_absolute_url(self, view_name):
def get_absolute_url(self, view_name=None):
def get_absolute_url(self, view_name): return '%s/%s/%s/View/%s'\ % (self._meta.app_label, self._meta.object_name.lower(), self.slug, view_name)
paginator = Paginator(categorizations_list, cyc_settings.CYCLOPE_PAGINATION['TEASER'])
paginator = Paginator(categorizations_list, self.items_per_page)
def get_http_response(self, request, slug=None, *args, **kwargs): category = Category.objects.get(slug=slug) # TODO(nicoechaniz):this hardcoded order_by es wrong. fix it. categorizations_list = category.categorizations.order_by('article__date')
objs.extend(list(ctype.objects.all().order_by('-content_object__creation_date')[:N]))
objs.extend(list(ctype.objects.all()[:N]))
def items(self): N = cyc_settings.CYCLOPE_RSS_LIMIT objs = [] for ctype in sites.site.base_content_types.keys(): objs.extend(list(ctype.objects.all().order_by('-content_object__creation_date')[:N])) return sorted(objs, key=lambda x: x.creation_date, reverse = True)[:N]
self.alias = alias
self.alias = alias[1:-1]
def __init__(self, origin, alias): self.value = template.Variable(origin)
context[self.alias.resolve(context)] = self.value.resolve(context)
context[unicode(self.alias.resolve(context))] = self.value.resolve(context)
def render(self, context): if isinstance(self.alias, template.Variable): context[self.alias.resolve(context)] = self.value.resolve(context) else: context[self.alias] = self.value.resolve(context) return ''
print obj.name
def get_response(self, request, host_template, content_object): category = content_object categorizations_list = category.categorizations.all()
self.children.append(modules.Feed( title=_('Codigo Sur, latest news'), css_classes = ('dbmodule-feed', 'right-area-modules',), draggable = False, deletable = False, collapsible= False, feed_url='http://codigosur.org/rss.php/36', limit=6 ))
def init_with_context(self, context): """ Use this method if you need to access the request context. """ from django.contrib.auth.models import User, Group user = context.get('user') managers = Group.objects.get(name='managers').user_set.all() admins = User.objects.filter(is_superuser=True)
du56 = self._format_timestring(int(objsize/57344.0)) dsl256 = self._format_timestring(int(objsize/262144.0)) dsl768 = self._format_timestring(int(objsize/786432.0)) t1 = self._format_timestring(int(objsize/1536000.0))
du56 = self._format_timestring(int(8*objsize/57344.0)) dsl256 = self._format_timestring(int(8*objsize/262144.0)) dsl768 = self._format_timestring(int(8*objsize/786432.0)) t1 = self._format_timestring(int(8*objsize/1536000.0))
def generate_estimation_js(self): lines = [] objsize = float(self.context.get_size()) du56 = self._format_timestring(int(objsize/57344.0)) dsl256 = self._format_timestring(int(objsize/262144.0)) dsl768 = self._format_timestring(int(objsize/786432.0)) t1 = self._format_timestring(int(objsize/1536000.0))
read('slc', 'publications', 'README.txt')
read('README.txt')
def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
version = '1.1.15dev'
version = '1.1.15'
def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
log.debug('Fetching...') return message
log.debug('Fetching metadata...') messageIn = psMessageReader(message) requestId = messageIn.getMessageId() dataBlockId = messageIn.getDataBlockIds()[0] data = messageIn.getData(dataBlockId) metadataRef = data.attribs['metadataIdRef'] md = messageIn.getMetadata(metadataRef) subjectNS = md.subject['ns'] subjectId = md....
def metadataKeyRequest(self, message): log.debug('Fetching...') # do something return message
logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.DEBUG, format="%(levelname)s: %(name)s: %(funcName)s : %(message)s")
def measurementStoreRequest(self,message): log.debug('Storing...') # do something return message