rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
peer_keys = sync(old_peer_keys, keys_at_peer, Key) | peer_keys = sync(old_peer_keys, keys_at_peer, Key, columns) | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
peer_persons = sync(old_peer_persons, persons_at_peer, Person) | peer_persons = sync(old_peer_persons, persons_at_peer, Person, columns) | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
if 'interface_ids' in columns: columns.remove('interface_ids') if 'dummybox_id' in columns: columns.remove('dummybox_id') | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) | |
peer_nodes = sync(old_peer_nodes, nodes_at_peer, Node) | peer_nodes = sync(old_peer_nodes, nodes_at_peer, Node, columns) | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
peer_slices = sync(old_peer_slices, slices_at_peer, Slice) | peer_slices = sync(old_peer_slices, slices_at_peer, Slice, columns) | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
iq['to'] = "pubsub.vplc27.inria.fr" | iq['to'] = "pubsub.%s" % self.id.host | def __iq(self, t="get"): iq = domish.Element((None, "iq")) iq['from'] = self.id.full() iq['to'] = "pubsub.vplc27.inria.fr" iq['type'] = t iq.addUniqueId() return iq |
if self.config.PLC_OMF: | if self.config.PLC_OMF_ENABLED: | def __init__(self, config = "/etc/planetlab/plc_config", encoding = "utf-8"): self.encoding = encoding |
required_min_role = tag_type ['min_role_id'] | required_min_role = node_tag['min_role_id'] | def call(self, auth, node_tag_id, value): node_tags = NodeTags(self.api, [node_tag_id]) if not node_tags: raise PLCInvalidArgument, "No such node tag %r"%node_tag_id node_tag = node_tags[0] |
if Timestamp.cast_long(node['last_pcu_reboot']) >= current_time - 60*20: | if node['last_pcu_reboot'] and Timestamp.cast_long(node['last_pcu_reboot']) >= current_time - 60*20: | def call(self, auth, node_fields): |
if len(set(person['person_ids']) & set(self.caller['person_ids'])) == 0: | if not self.call.can_update(person): | def call(self, auth, person_tag_id, value): person_tags = PersonTags(self.api, [person_tag_id]) if not person_tags: raise PLCInvalidArgument, "No such person setting %r"%person_tag_id person_tag = person_tags[0] |
required_min_role = tag_type ['min_role_id'] | required_min_role = person_tag['min_role_id'] | def call(self, auth, person_tag_id, value): person_tags = PersonTags(self.api, [person_tag_id]) if not person_tags: raise PLCInvalidArgument, "No such person setting %r"%person_tag_id person_tag = person_tags[0] |
if not self.call.can_update(person): | if not self.caller.can_update(person): | def call(self, auth, person_tag_id, value): person_tags = PersonTags(self.api, [person_tag_id]) if not person_tags: raise PLCInvalidArgument, "No such person setting %r"%person_tag_id person_tag = person_tags[0] |
shell = Shell() UpdateNode = self.api.callable('UpdateNode') UpdateNode(shell.auth, node['node_id'], {'hostname': node['hostname']}) def remove_node(self, node, commit = True): """ Unassociate a node with this peer. """ remove = Row.remove_object(Node, 'peer_node') remove(self, node, commit) | def add_node(self, node, peer_node_id, commit = True): """ Associate a local node entry with this peer. """ | |
shell = Shell() UpdateNode = self.api.callable('UpdateNode') UpdateNode(shell.auth, node['node_id'], {'hostname': node['hostname']}) | from PLC.Methods.UpdateNode import UpdateNode UpdateNode.__call__(UpdateNode(self.api), auth, node['node_id'], {'hostname': node['hostname']}) def remove_node(self, node, commit = True): """ Unassociate a node with this peer. """ remove = Row.remove_object(Node, 'peer_node') remove(self, node, commit) from PLC.Me... | def remove_node(self, node, commit = True): """ Unassociate a node with this peer. """ remove = Row.remove_object(Node, 'peer_node') remove(self, node, commit) |
node=api.GetNodes(interface['node_id'])[0] return node_belong_to_person (api, node, person) | node=Nodes(api,[interface['node_id']])[0] return AuthorizeHelpers.node_belong_to_person (api, node, person) | def interface_belongs_to_person (api,interface, person): try: node=api.GetNodes(interface['node_id'])[0] return node_belong_to_person (api, node, person) except: return False |
site=api.GetSites(node['site_id'])[0] return person_belongs_to_site (api, person, site) | site=Sites(api,[node['site_id']])[0] return AuthorizeHelpers.person_belongs_to_site (api, person, site) | def node_belongs_to_person (api, node, person): try: site=api.GetSites(node['site_id'])[0] return person_belongs_to_site (api, person, site) except: return False |
try: return GetNodes(node_id_or_hostname_in_slice)[0]['node_id'] in slice['node_ids'] | try: return Nodes(api,node_id_or_hostname_in_slice)[0]['node_id'] in slice['node_ids'] | def node_id_or_hostname_in_slice (api, node_id_or_hostname, slice): if isinstance (node_id_or_hostname,int): return node_id_or_hostname in slice['node_ids'] else: try: return GetNodes(node_id_or_hostname_in_slice)[0]['node_id'] in slice['node_ids'] except:return False |
def nodefamily (self, auth, node_id, arch): | def nodefamily (self, auth, node_id, fcdistro, arch): | def nodefamily (self, auth, node_id, arch): |
fcdistro = GetNodeFcdistro (self.api).call(auth, node_id) if not fcdistro: fcdistro = self.api.config.PLC_FLAVOUR_NODE_FCDISTRO | def nodefamily (self, auth, node_id, arch): | |
def extensions (self, auth, node_id, arch): | def extensions (self, auth, node_id, fcdistro, arch): | def extensions (self, auth, node_id, arch): try: return [ "%s-%s"%(e,arch) for e in GetNodeExtensions(self.api).call(auth,node_id).split() ] except: return [] |
return [ "%s-%s"%(e,arch) for e in GetNodeExtensions(self.api).call(auth,node_id).split() ] | return [ "%s-%s-%s"%(e,fcdistro,arch) for e in GetNodeExtensions(self.api).call(auth,node_id).split() ] | def extensions (self, auth, node_id, arch): try: return [ "%s-%s"%(e,arch) for e in GetNodeExtensions(self.api).call(auth,node_id).split() ] except: return [] |
return { 'nodefamily' : self.nodefamily(auth,node_id, arch), 'extensions' : self.extensions(auth,node_id, arch), | return { 'nodefamily' : self.nodefamily(auth,node_id, fcdistro, arch), 'extensions' : self.extensions(auth,node_id, fcdistro, arch), | def call(self, auth, node_id_or_name): # Get node information nodes = Nodes(self.api, [node_id_or_name]) if not nodes: raise PLCInvalidArgument, "No such node %r"%node_id_or_name node = nodes[0] node_id = node['node_id'] |
if len(build_sh_spec['kargs']) > 0: for karg in build_sh_spec['kargs']: build_sh_options += ' -k "%s"'%karg | for karg in build_sh_spec['kargs']: build_sh_options += ' -k "%s"'%karg | def build_command(self, node_type, build_sh_spec, node_image, type, floppy_file, log_file): |
build_sh_spec['kargs'].append(tag['value'].split()) | build_sh_spec['kargs'] += tag['value'].split() | def call(self, auth, node_id_or_hostname, action, filename, options = []): |
raise PLCPermissionDenied, "Not allowed to modify the specified person setting, requires role %d",required_min_role | raise PLCPermissionDenied, "Not allowed to modify the specified person setting, requires role %d" % required_min_role | def call(self, auth, person_tag_id, value): person_tags = PersonTags(self.api, [person_tag_id]) if not person_tags: raise PLCInvalidArgument, "No such person setting %r"%person_tag_id person_tag = person_tags[0] |
self.command_que.put(self.delete_node, node) | self.command_queue.put((self.delete_node, node)) | def delete_slice_resources(iq): for i in iq.query.elements(): node = i['node'] if node.startswith(resource_prefix): self.command_que.put(self.delete_node, node) |
xmppserver = self.config.PLC_OMF_XMPP_SERVER xmppuser = "@".join([self.config.PLC_OMF_XMPP_USER, xmppserver]) xmpppass = self.config.PLC_OMF_XMPP_PASSWORD | xmppserver = config.PLC_OMF_XMPP_SERVER xmppuser = "@".join([config.PLC_OMF_XMPP_USER, xmppserver]) xmpppass = config.PLC_OMF_XMPP_PASSWORD | def delete_resource(self, slice, resource): self.command_queue.put(( self.delete_node, "/".join([self.DOMAIN,slice,self.RESOURCES,resource]) )) |
vref = GetSliceVref (self.api).call(auth,slice_id) if vref: return vref | def call(self, auth, slice_id_or_name): # Get slice information slices = Slices(self.api, [slice_id_or_name]) if not slices: raise PLCInvalidArgument, "No such slice %r"%slice_id_or_name slice = slices[0] slice_id = slice['slice_id'] | |
return "%s-%s-%s"%(pldistro,fcdistro,arch) | if vref: return "%s-%s-%s"%(vref,fcdistro,arch) else: return "%s-%s-%s"%(pldistro,fcdistro,arch) | def call(self, auth, slice_id_or_name): # Get slice information slices = Slices(self.api, [slice_id_or_name]) if not slices: raise PLCInvalidArgument, "No such slice %r"%slice_id_or_name slice = slices[0] slice_id = slice['slice_id'] |
if 'is_primary' in self and self['is_primary'] is True: for key in ['gateway', 'dns1']: if key not in self or not self[key]: | for key in ['gateway', 'dns1']: if key not in self or not self[key]: if 'is_primary' in self and self['is_primary'] is True: | def validate(self): """ Flush changes back to the database. """ |
raise PLCPermissionDenied, "Not a member of the person's persons: %s"%person['person_ids'] | raise PLCPermissionDenied, "person_id %s doesn't have access to person_tag_id %s" % ( person['person_id'], person_tag['person_tag_id']) | def call(self, auth, person_tag_id, value): person_tags = PersonTags(self.api, [person_tag_id]) if not person_tags: raise PLCInvalidArgument, "No such person setting %r"%person_tag_id person_tag = person_tags[0] |
else: value = str(api.db.quote(value)) | value = str(api.db.quote(value)) | def check_modifiers(field): if field[0] in modifiers.keys(): modifiers[field[0]] = True field = field[1:] return check_modifiers(field) return field |
self.requests = {} | def event_authenticated(self, xs): BaseClient.event_authenticated(self, xs) self.requests = {} xs.addObserver("/iq/pubsub/create", self.result_create_node) xs.addObserver("/iq/pubsub/delete", self.result_delete_node) xs.addObserver("/iq/query[@xmlns='http://jabber.org/protocol/disco#items']", self.result_discover) xs.a... | |
xs.addObserver("/iq/pubsub/configure", self.result_configure_node) | xs.addObserver("/iq/pubsub/configure/x", self.result_configure_node) xs.addObserver("/iq/pubsub/configure/error", self.result_configure_node) | def event_authenticated(self, xs): BaseClient.event_authenticated(self, xs) self.requests = {} xs.addObserver("/iq/pubsub/create", self.result_create_node) xs.addObserver("/iq/pubsub/delete", self.result_delete_node) xs.addObserver("/iq/query[@xmlns='http://jabber.org/protocol/disco#items']", self.result_discover) xs.a... |
def log(self, line) | def log(self, line): | def log(self, line) log = open("/var/log/plc_ratelimit.log", "a") date = datetime.now().strftime("%d/%m/%y %H:%M") log.write("%s - %s\n" % (date, line)) log.flush() |
[n[0],n[1],n[2],0.,0.,0.], [0.,0.,0.,n[0],n[1],n[2]], | [ n[0], n[1], n[2], 0., 0., 0. ], [ 0., 0., 0., n[0], n[1], n[2]] | def bar3e(ex,ey,ez,ep): """ Compute element stiffness matrix for three dimensional bar element. Parameters: ex = [x1 x2] ey = [y1 y2] element node coordinates ez = [z1 z2] ep = [E A] E: Young's modulus A: Cross sections area Returns: Ke stiffness matrix, dim(Ke) = 6 x 6 """ E = ep... |
[1,-1], [-1,1], | [ 1,-1], [-1, 1] | def bar3e(ex,ey,ez,ep): """ Compute element stiffness matrix for three dimensional bar element. Parameters: ex = [x1 x2] ey = [y1 y2] element node coordinates ez = [z1 z2] ep = [E A] E: Young's modulus A: Cross sections area Returns: Ke stiffness matrix, dim(Ke) = 6 x 6 """ E = ep... |
[n[0],n[1],n[2],0.,0.,0.], [0.,0.,0.,n[0],n[1],n[2]], | [ n[0], n[1], n[2], 0. , 0. , 0. ], [ 0. , 0. , 0. , n[0], n[1], n[2]] | def bar3s(ex,ey,ez,ep,ed): """ Compute normal force in three dimensional bar element. Parameters: ex = [x1 x2] ey = [y1 y2] element node coordinates ez = [z1 z2] ep = [E A] E: Young's modulus A: Cross sections area ed = [u1 ... u6] element displacements Returns: es = [N] normal force... |
[1,-1], [-1,1], | [ 1,-1], [-1, 1] | def bar3s(ex,ey,ez,ep,ed): """ Compute normal force in three dimensional bar element. Parameters: ex = [x1 x2] ey = [y1 y2] element node coordinates ez = [z1 z2] ep = [E A] E: Young's modulus A: Cross sections area ed = [u1 ... u6] element displacements Returns: es = [N] normal force... |
print "N =",N | def bar3s(ex,ey,ez,ep,ed): """ Compute normal force in three dimensional bar element. Parameters: ex = [x1 x2] ey = [y1 y2] element node coordinates ez = [z1 z2] ep = [E A] E: Young's modulus A: Cross sections area ed = [u1 ... u6] element displacements Returns: es = [N] normal force... | |
[ n1[0], n1[1], n1[2], 0, 0, 0, 0, 0, 0, 0, 0, 0], [ n2[0], n2[1], n2[2], 0, 0, 0, 0, 0, 0, 0, 0, 0], [ n3[0], n3[1], n3[2], 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, n1[0], n1[1], n1[2], 0, 0, 0, 0, 0, 0], [ 0, 0, 0, n2[0], n2[1], n2[2], 0, 0, 0, 0, 0, 0], [ 0, 0, 0, n3[0], n3[1], n3[2], 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, ... | [ n1[0], n1[1], n1[2], 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ n2[0], n2[1], n2[2], 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ n3[0], n3[1], n3[2], 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, n1[0], n1[1], n1[2], 0, 0, 0... | def beam3e(ex,ey,ez,eo,ep,eq=None): """ Calculate the stiffness matrix for a 3D elastic Bernoulli beam element. Parameters: ex = [x1 x2] ey = [y1 y2] ez = [z1 z2] element node coordinates eo = [xz yz zz] orientation of local z axis ep = [E G A Iy Iz Kv] element properties E: Young's modulus G: ... |
[ n1[0], n1[1], n1[2], 0, 0, 0, 0, 0, 0, 0, 0, 0], [ n2[0], n2[1], n2[2], 0, 0, 0, 0, 0, 0, 0, 0, 0], [ n3[0], n3[1], n3[2], 0, 0, 0, 0, 0, 0, 0, 0, 0], [ 0, 0, 0, n1[0], n1[1], n1[2], 0, 0, 0, 0, 0, 0], [ 0, 0, 0, n2[0], n2[1], n2[2], 0, 0, 0, 0, 0, 0], [ 0, 0, 0, n3[0], n3[1], n3[2], 0, 0, 0, 0, 0, 0], [ 0, 0, 0, 0, ... | [ n1[0], n1[1], n1[2], 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ n2[0], n2[1], n2[2], 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ n3[0], n3[1], n3[2], 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, n1[0], n1[1], n1[2], 0, 0, 0... | def beam3s(ex,ey,ez,eo,ep,ed,eq=None,n=None): """ Calculate the variation of the section forces and displacements along a three-dimensional beam element. Parameters: ex = [x1 x2] element node coordinates ey = [y1 y2] ez = [z1 z2] eo = [xz yz zz] orientation of local z axis ep = [E G A Iy ... |
Dm = linalg.inv(Cm(ix_((0,1,3),(0,1,3)))) | Dm = linalg.inv(Cm[ix_((0,1,3),(0,1,3))]) | def plante(ex,ey,ep,D,eq=None): """ Calculate the stiffness matrix for a triangular plane stress or plane strain element. Parameters: ex = [x1,x2,x3] element coordinates ey = [y1,y2,y3] ep = [ptype,t] ptype: analysis type t: thickness D constitutive matrix eq = [[bx], ... |
Dm = D(ix_((1,2,4),(1,2,4))) | Dm = D[ix_((0,1,3),(0,1,3))] | def plante(ex,ey,ep,D,eq=None): """ Calculate the stiffness matrix for a triangular plane stress or plane strain element. Parameters: ex = [x1,x2,x3] element coordinates ey = [y1,y2,y3] ep = [ptype,t] ptype: analysis type t: thickness D constitutive matrix eq = [[bx], ... |
name_authority = models.ForeignKey( 'name_authority', verbose_name = 'Name Authority' ) label = models.CharField( max_length=100, help_text='A human-readable label for the resource type.' ) | def __unicode__(self): return self.name | |
label = models.CharField( max_length=100, help_text='A human-readable label for the resource type.' ) | def __unicode__(self): return self.name | |
return HttpResponse('Hello') | def detail(request, given_uri): # return HttpResponse(given_uri) return HttpResponse('Hello') resolveme = get_list_or_404(redirection, Q(uri_string = '/uri-gin/' + given_uri) | Q(uri_string = '/uri-gin/' + given_uri + '/')) if len(resolveme) > 1: return render_to_response( 'uriresolve/duplicateuri.html', { 'requestedU... | |
def test_include_file_inside_code(self): | def test_include_file_disabled_inside_code(self): | def test_include_file_inside_code(self): lines = ['<[code]', '>>>test_file<<<', '[code]>'] expected = ['\\defverbatim[colored]\\mhifagamigghjgmmckbhaimjjhbfemio{\n\\begin{lstlisting}test file content\\end{lstlisting}\n}\n', '\n\\mhifagamigghjgmmckbhaimjjhbfemio\n', '', ''] out = convert2beamer(lines) self.assertEqual(o... |
expected = ['\\defverbatim[colored]\\mhifagamigghjgmmckbhaimjjhbfemio{\n\\begin{lstlisting}test file content\\end{lstlisting}\n}\n', '\n\\mhifagamigghjgmmckbhaimjjhbfemio\n', '', ''] | expected = ['\\defverbatim[colored]\\mfkjiamnpineejahopjoapckhioohfpa{\n\\begin{lstlisting}>>>test_file<<<\\end{lstlisting}\n}\n', '\n\\mfkjiamnpineejahopjoapckhioohfpa\n', '', ''] | def test_include_file_inside_code(self): lines = ['<[code]', '>>>test_file<<<', '[code]>'] expected = ['\\defverbatim[colored]\\mhifagamigghjgmmckbhaimjjhbfemio{\n\\begin{lstlisting}test file content\\end{lstlisting}\n}\n', '\n\\mhifagamigghjgmmckbhaimjjhbfemio\n', '', ''] out = convert2beamer(lines) self.assertEqual(o... |
line = ">>>test_file2<<<" out = include_file_recursive([line]) | out = include_file_recursive('test_file2') | def test_include_file_recursive_works(self): expected = ['content from test_file2', 'test file content'] line = ">>>test_file2<<<" out = include_file_recursive([line]) self.assertEqual(expected, out) |
line = ">>>test_file3<<<" | def test_include_file_recursive_honors_nowiki(self): line = ">>>test_file3<<<" expected = ['content from test_file3', '<[nowiki]', '>>>test_file<<<', '[nowiki]>'] out = include_file_recursive([line]) self.assertEqual(expected, out) | |
out = include_file_recursive([line]) | out = include_file_recursive('test_file3') | def test_include_file_recursive_honors_nowiki(self): line = ">>>test_file3<<<" expected = ['content from test_file3', '<[nowiki]', '>>>test_file<<<', '[nowiki]>'] out = include_file_recursive([line]) self.assertEqual(expected, out) |
def test_fragile(self): lines = ['==== foo ====[fragile]', 'foo'] expected = ['\n', '\\begin{frame}[fragile]\n \\frametitle{foo}\n \n', 'foo', '', ' \n\\end{frame}\n'] out = convert2beamer(lines) self.assertEqual(out, expected) | def test_itemizeclose_column(self): lines = ['* foo', '[[[6cm]]]'] expected = ['\n', '\\begin{itemize}\n \\item foo', '\\end{itemize}\n\\column{6cm}', ''] out = convert2beamer(lines) self.assertEqual(out,expected) | |
lines = ['==== foo ====', '@FRAMEFOOTER=\\buge bar\\3', '==== bar ===='] expected = ['\n', '\\begin{frame}\n \\frametitle{foo}\n \n', '', ' \n \\end{frame}\n\\begin{frame}\n \\frametitle{bar}\n \n', '', ' \\buge bar\\3 \n \\end{frame}\n'] | lines = ['==== foo ====', '@FRAMEFOOTER=\\huge bar 3', '==== bar ===='] expected = ['\n', '\\begin{frame}\n \\frametitle{foo}\n \n', '', ' \n\\end{frame}\n\\begin{frame}\n \\frametitle{bar}\n \n', '', ' \\huge bar 3 \n\\end{frame}\n'] | def test_subexp_footer(self): lines = ['==== foo ====', '@FRAMEFOOTER=\\buge bar\\3', '==== bar ===='] expected = ['\n', '\\begin{frame}\n \\frametitle{foo}\n \n', '', ' \n \\end{frame}\n\\begin{frame}\n \\frametitle{bar}\n \n', '', ' \\buge bar\\3 \n \\end{frame}\n'] out = convert2beamer(lines) self.assertEqual(out... |
if not server: print "Please provide valid server url by fliesrc or by '--server' option" sys.exit() | def main(): config = FliesConfig() server = config.get_config_value("server") project_id = config.get_config_value("project.id") iteration_id = config.get_config_value("project.iteration.id") user = config.get_config_value("user") apikey = config.get_config_value("apikey") name = '' desc = '' try: opts, args = getopt.... | |
if not options['name']: print "Please provide Project name by '--name' option" | if not options['project_name']: print "Please provide Project name by '--project-name' option" | def _create_project(self, args): """ Create project with the project id @param args: project id """ if self.user_name and self.apikey: flies = FliesResource(self.url, self.user_name, self.apikey) else: print "Please provide username and apikey in flies.ini" sys.exit() |
sys.exit() | def _get_iteration(self): if not self.options['server']: print "Please provide valid server url by fliesrc or by '--server' option" sys.exit() if not self.options['iteration_id'] or not self.options['project_id']: print 'Please use flies iteration info --project=project_id --iteration=iteration_id to retrieve the iter... | |
config.read([projectconfig, os.path.expanduser("~/.fliesrc")]) server = config.get('Config', 'server') projectid = config.get('Config', 'project.id') iterationid = config.get('Config', 'project.iteration.id') user = config.get('Config', 'user') apikey = config.get('Config', 'apikey') return server, projectid, iteration... | configfile = config.read([projectconfig, os.path.expanduser("~/.fliesrc")]) if configfile: server = config.get('Config', 'server') projectid = config.get('Config', 'project.id') iterationid = config.get('Config', 'project.iteration.id') user = config.get('Config', 'user') apikey = config.get('Config', 'apikey') return ... | def get_config_var(): projectconfig = "./.fliesrc" config = ConfigParser.ConfigParser() config.read([projectconfig, os.path.expanduser("~/.fliesrc")]) server = config.get('Config', 'server') projectid = config.get('Config', 'project.id') iterationid = config.get('Config', 'project.iteration.id') user = config.get('Conf... |
"Use 'flies help' for the full list of commands\n") | "Use 'flies help' for the full list of commands") | def _PrintUsage(self): print ('\nClient for talking to a Flies Server\n\n' 'basic commands:\n\n' 'list List all available projects\n' 'projectinfo Retrieve a project\n' 'iterationinfo Retrieve a iteration\n\n' "Use 'flies help' for the full list of commands\n") |
items = {'links':[],'extensions':[], 'textFlowsTargets':textflowtargets} | items = {'links':[],'extensions':[], 'textFlowTargets':textflowtargets} | def _create_translation(self, filepath): if '/' in filepath: file = filepath.split('/')[-1] path = filepath else: file = filepath path = os.path.join(os.getcwd(), file) |
self.roject_id = config.get_config_value("project.id") | self.project_id = config.get_config_value("project.id") | def __init__(self, opts, args): config = FliesConfig() self.server = config.get_config_value("server") self.roject_id = config.get_config_value("project.id") self.iteration_id = config.get_config_value("project.iteration.id") self.user = config.get_config_value("user") self.apikey = config.get_config_value("apikey") na... |
name = '' desc = '' for o, a in opts: if o in ("--server"): | self.name = '' self.desc = '' if opts: for o, a in opts: if o in ("--server"): | def __init__(self, opts, args): config = FliesConfig() self.server = config.get_config_value("server") self.roject_id = config.get_config_value("project.id") self.iteration_id = config.get_config_value("project.iteration.id") self.user = config.get_config_value("user") self.apikey = config.get_config_value("apikey") na... |
self.command, self.args = args[0], args[1:] def _PrintUsage(): print ('\nClient for talking to a Flies Server\n' 'basic commands:\n' | if args: self.command, self.args = args[0], args[1:] else: self.command = '' def _PrintUsage(self): print ('\nClient for talking to a Flies Server\n\n' 'basic commands:\n\n' | def __init__(self, opts, args): config = FliesConfig() self.server = config.get_config_value("server") self.roject_id = config.get_config_value("project.id") self.iteration_id = config.get_config_value("project.iteration.id") self.user = config.get_config_value("user") self.apikey = config.get_config_value("apikey") na... |
'iterationinfo Retrieve a iteration\n' | 'iterationinfo Retrieve a iteration\n\n' | def _PrintUsage(): print ('\nClient for talking to a Flies Server\n' 'basic commands:\n' 'list List all available projects\n' 'projectinfo Retrieve a project\n' 'iterationinfo Retrieve a iteration\n' "Use 'flies help' for the full list of commands\n") |
if len(args) < 2: | if not self.args[0]: | def _CreateProject(self): if not self.server: print "Please provide valid server url by fliesrc or by '--server' option" sys.exit() if len(args) < 2: print "Error: Not enough arguments for executing command" sys.exit() if self.user and self.apikey : flies = FliesClient(self.server, self.user, self.apikey) else: print ... |
result = flies.create_project(self.id, self.name, self.desc) | result = flies.create_project(self.args[0], self.name, self.desc) | def _CreateProject(self): if not self.server: print "Please provide valid server url by fliesrc or by '--server' option" sys.exit() if len(args) < 2: print "Error: Not enough arguments for executing command" sys.exit() if self.user and self.apikey : flies = FliesClient(self.server, self.user, self.apikey) else: print ... |
if not self.project_id: print "Please provide PROJECT_ID for creating iteration" sys.exit() | def _CreateIteration(self): if self.user and self.apikey : flies = FliesClient(self.server, self.user, self.apikey) else: print "Please provide username and apikey in .fliesrc" sys.exit() try: result = flies.create_iteration(self.project_id, self.id, self.name, self.desc) print "Create iteration of project success" ex... | |
result = flies.create_iteration(self.project_id, self.id, self.name, self.desc) | result = flies.create_iteration(self.project_id, self.args[0], self.name, self.desc) | def _CreateIteration(self): if self.user and self.apikey : flies = FliesClient(self.server, self.user, self.apikey) else: print "Please provide username and apikey in .fliesrc" sys.exit() try: result = flies.create_iteration(self.project_id, self.id, self.name, self.desc) print "Create iteration of project success" ex... |
for project in projects: print "*"*40 print project | for project in projects: print "*"*40 print project else: print "No project exists on the server" | def list_projects(server): flies = Flies(server) res, content = flies.get_projects() print 'Status: '+res['status'] if res.get('status') == '200': projects = json.loads(content) for project in projects: print "*"*40 print project |
value = field_type.decoder(encoded[pos:]) | value = field_type.decoder(encoded[pos:pos+field_type.fixed_size]) | def decode(cls, encoded, taxonomy=None): """Decode a field from a byte array. |
format(field.value, depth + 1) | self.format(field.value, depth + 1) | def _format_field(self, field, fieldspec, index, depth, max_fs, max_tn): """Format a single field on a line""" typename = types.name_for_type(field.type_.type_id) self._writer.write("{0:<{width}} {1:<{tn_width}} ".format(fieldspec, typename, width=max_fs, tn_width=max_tn) ) if field.is_type(types.FUDGEMSG_TYPE_ID): for... |
if ordinal: | if ordinal is not None: | def encode(self, writer, taxonomy=None): """Encode a Field. |
if reachedType not in pathToType.keys(): | if reachedType not in pathToType.keys() and transforms: | def typesWithPathOfLength(length): '''Returns the lists of known paths of a given length''' result = [] for type,path in pathToType.items(): if len(path) == length: result.append(type) return result |
self.announce("(%s has joined the game!)"%self.nick) pl = [] for player in players: pl.append(player.nick) self.announce("D_PLAYERS %s"%(" ".join(pl))) | self.announce_players() | def login(self,data): tok = data.split(' ') self.typing = False if tok[0] == 'TYPING': self.typing = True elif tok[0] == 'NOT_TYPING': self.typing = False |
output += dbuf | roll = self.dice(dbuf) if roll: color.append(ansi(COLOR['gray'])) output += color[-1] + '[' + roll[0] + ': ' color.append(ansi(COLOR['green'])) output += color[-1] + roll[1] color.pop() output += color[-1] + ']' color.pop() output += color[-1] else: output += dbuf | def wrap(self,data): ''' Miten ois v2 mika lukee koko paskan kirjain kirjaimelta -> varien sailytys onnistuis ''' # First talking quote = False offtopic = False dice = False cmode = False output = '' dbuf = '' cbuf = '' color = [ansi(COLOR['white'])] print data for char in data: |
if player.nick.lower() == who or who in player.name.lower(): player.write("(%s%s tells you: %s))"%(ansi(COLOR['magneta']),self.name,txt)) elif player.nick.lower() == self.nick.lower(): player.write("(%sYou tell %s: %s)"%(ansi(COLOR['magneta']),who,txt)) elif player.gm: player.write("(%s%s tells %s: %s)"%(ansi(COLOR['ye... | if player.nick.lower() == who or who in player.name.lower(): player.write("%s(%s%s tells you: %s))"%(ansi(COLOR['magneta']),ansi(COLOR['magneta']),self.name,txt));told=1 elif player.nick.lower() == self.nick.lower(): pass elif player.gm: player.write("%s(%s%s tells %s: %s)"%(ansi(COLOR['yellow']),ansi(COLOR['yellow']),... | def tell(self,tok): who = tok[0].lower() txt = " ".join(tok[1:]) tells = [] for player in players: if player.nick.lower() == who or who in player.name.lower(): player.write("(%s%s tells you: %s))"%(ansi(COLOR['magneta']),self.name,txt)) elif player.nick.lower() == self.nick.lower(): player.write("(%sYou tell %s: %s)"%(... |
elif tok[0] == '/tell': self.tell(tok[1:]) | elif tok[0] == '/tell': self.tell(tok[1:]);self.typing = False;self.announce_players() | def game(self,data): if len(data) == 0: return data = data.decode('utf-8') tok = data.split(' ') if tok[0] == 'TYPING': self.typing = True;self.announce_players() elif tok[0] == 'NOT_TYPING': self.typing = False;self.announce_players() elif tok[0] == '/name': self.setname(" ".join(tok[1:]))#self.name = ;self.regex = re... |
if char == 'd': | if char.isdigit(): dbuf += char continue elif char == 'd': | def wrap(self,data): ''' Miten ois v2 mika lukee koko paskan kirjain kirjaimelta -> varien sailytys onnistuis ''' # First talking quote = False offtopic = False dice = False cmode = False output = '' dbuf = '' cbuf = '' color = [ansi(COLOR['white'])] print data for char in data: |
'/re':'%s'%ansi('red'), '/gr':'%s'%ansi('green'), '/bl':'%s'%ansi('blue'), '/ye':'%s'%ansi('yellow')} | '/re':'%s'%ansi(COLOR['red']), '/gr':'%s'%ansi(COLOR['green']), '/bl':'%s'%ansi(COLOR['blue']), '/ye':'%s'%ansi(COLOR['yellow']), '/cl':'CLEAR'} | def ansi(code): return CSI + code |
color.append(ansi(COLOR['red'])) output += color[-1] + roll | color.append(ansi(COLOR['gray'])) output += color[-1] + '[' + roll[0] + ': ' color.append(ansi(COLOR['green'])) output += color[-1] + roll[1] color.pop() output += color[-1] + ']' | def wrap(self,data): ''' Miten ois v2 mika lukee koko paskan kirjain kirjaimelta -> varien sailytys onnistuis ''' # First talking quote = False offtopic = False dice = False cmode = False output = '' dbuf = '' cbuf = '' color = [ansi(COLOR['white'])] print data ''' for tok in data.split(' '): if len(tok) == 0: print "... |
try: c = commands[cbuf]; output += c | try: c = commands[cbuf] if c == 'CLEAR': color.pop() output += color[-1] else: output += c color.append(c) | def wrap(self,data): ''' Miten ois v2 mika lukee koko paskan kirjain kirjaimelta -> varien sailytys onnistuis ''' # First talking quote = False offtopic = False dice = False cmode = False output = '' dbuf = '' cbuf = '' color = [ansi(COLOR['white'])] print data ''' for tok in data.split(' '): if len(tok) == 0: print "... |
if len(dbuf) > 0: output += self.dice(dbuf) | if len(dbuf) > 0: roll=self.dice(dbuf) if roll: color.append(ansi(COLOR['gray'])) output += color[-1] + '[' + roll[0] + ': ' color.append(ansi(COLOR['green'])) output += color[-1] + roll[1] color.pop() output += color[-1] + ']' color.pop() output += color[-1] else: output += dbuf | def wrap(self,data): ''' Miten ois v2 mika lukee koko paskan kirjain kirjaimelta -> varien sailytys onnistuis ''' # First talking quote = False offtopic = False dice = False cmode = False output = '' dbuf = '' cbuf = '' color = [ansi(COLOR['white'])] print data ''' for tok in data.split(' '): if len(tok) == 0: print "... |
if data[0] == '!': self.announce('''%s'''%(data[1:])) | elif data[0] == '!': self.announce('''(%s: %s'''%(self.name,data)) elif data[0] == ' | def game(self,data): if len(data) == 0: return data = data.decode('utf-8') tok = data.split(' ') if tok[0] == 'TYPING': self.typing = True;self.announce_players() elif tok[0] == 'NOT_TYPING': self.typing = False;self.announce_players() elif tok[0] == '/name': self.name = " ".join(tok[1:]) else: if data[0] == '*': self.... |
def dice(self,x): | def dice(self,data): x=data | def dice(self,x): roll = [] # Dices we still need to roll [add/subtract, dice string] rolled = [] # Dices we have rolled: [add/subtract, dice string, result] |
return "%s (%s)"%(str(tot), "".join(output)) | return data[1:],str(tot) | def dice(self,x): roll = [] # Dices we still need to roll [add/subtract, dice string] rolled = [] # Dices we have rolled: [add/subtract, dice string, result] |
elif tok[0] == '/name': self.name = " ".join(tok[1:]);self.regex = re.compile(self.name,re.IGNORECASE) | elif tok[0] == '/name': self.setname(" ".join(tok[1:])) | def game(self,data): if len(data) == 0: return data = data.decode('utf-8') tok = data.split(' ') if tok[0] == 'TYPING': self.typing = True;self.announce_players() elif tok[0] == 'NOT_TYPING': self.typing = False;self.announce_players() elif tok[0] == '/name': self.name = " ".join(tok[1:]);self.regex = re.compile(self.n... |
self.re_off = re.compile('\(.*?\)*?') | self.re_off = re.compile('\(.*?\)') | def connectionMade(self): self.handle = self.login self.state = 0 self.color = '' self.typing = False self.gm = False self.re_dice = re.compile("(?:\!\d*d\d*(?:\+|\-)*)(?:(?:(?:\d*d\d*)|\d*)(?:\+|\-)*)*",re.IGNORECASE) self.re_quote = re.compile('".*?"') self.re_off = re.compile('\(.*?\)*?') |
elif data[0] == '(': self.announce('''(%s: %s'''%(self.name,data[1:])) | elif data[0] == '(': self.announce('''(%s: %s'''%(self.nick,data[1:])) | def game(self,data): if len(data) == 0: return data = data.decode('utf-8') tok = data.split(' ') if tok[0] == 'TYPING': self.typing = True;self.announce_players() elif tok[0] == 'NOT_TYPING': self.typing = False;self.announce_players() elif tok[0] == '/name': self.setname(" ".join(tok[1:]))#self.name = ;self.regex = re... |
'/re':'%s'%(ansi('red'), '/gr':'%s'%(ansi('green'), '/bl':'%s'%(ansi('blue'), '/ye':'%s'%(ansi('yellow')} | '/re':'%s'%ansi('red'), '/gr':'%s'%ansi('green'), '/bl':'%s'%ansi('blue'), '/ye':'%s'%ansi('yellow')} | def ansi(code): return CSI + code |
if char == '/' and not cmode: cmode = 1 cbuf += char continue elif cmode == 1: cmode = 2 cbuf += char continue elif cmode == 2: cmode = False cbuf += char try: c = commands[cbuf]; output += c except: output += cbuf cbuf = '' continue | def wrap(self,data): ''' Miten ois v2 mika lukee koko paskan kirjain kirjaimelta -> varien sailytys onnistuis ''' # First talking quote = False offtopic = False dice = False output = '' dbuf = '' color = [ansi(COLOR['white'])] print data ''' for tok in data.split(' '): if len(tok) == 0: print "funny",data.split(' ');c... | |
self.announce("(%s has joined the game!)"%self.nick) | def login(self,data): tok = data.split(' ') self.typing = False if tok[0] == 'TYPING': self.typing = True elif tok[0] == 'NOT_TYPING': self.typing = False | |
q = simplejson.loads(qstr) | q = json.loads(qstr) | def cmd_find(fb, qstr): """print all ids matching a given constraint. if the query string starts with "{" it is treated as json. otherwise it is treated as o-rison. %prog find """ if qstr.startswith('{'): q = simplejson.loads(qstr) else: q = rison.loads('(' + qstr + ')') if 'id' not in q: q['id'] = None results = f... |
q = simplejson.loads(qstr) | q = json.loads(qstr) | def cmd_q(fb, qstr): """run a freebase query. if the query string starts with "{" it is treated as json. otherwise it is treated as o-rison. dump the result as json. %prog q """ if qstr.startswith('{'): q = simplejson.loads(qstr) else: q = rison.loads('(' + qstr + ')') # done this way for streaming first = True for... |
print simplejson.dumps(result, indent=2), | print json.dumps(result, indent=2), | def cmd_q(fb, qstr): """run a freebase query. if the query string starts with "{" it is treated as json. otherwise it is treated as o-rison. dump the result as json. %prog q """ if qstr.startswith('{'): q = simplejson.loads(qstr) else: q = rison.loads('(' + qstr + ')') # done this way for streaming first = True for... |
print simplejson.dumps(link, indent=2) | print json.dumps(link, indent=2) | def cmd_log(fb, id): """log changes pertaining to a given id. INCOMPLETE %prog log /some/id """ null = None true = True false = False baseq = { 'type': '/type/link', 'source': null, 'master_property': null, 'attribution': null, 'timestamp': null, 'operation': null, 'valid': null, 'sort': '-timestamp' }; queries = ... |
form = {'appid':appid, 'to_appid':to} | form = {'appid':appid, 'to_appid':to_appid} | def move_app(self, appid, to_appid): service = '/appeditor/move_app' |
def cmd_dump_type(fb, baseid, follow_types=True): | def cmd_dump_type(fb, typeid, follow_types=True): | def cmd_dump_type(fb, baseid, follow_types=True): """dump a type to stdout %prog dump_type typeid [follow_types=True] Dump a type by outputting a json representation of the type and properties involved. """ print >> sys.stdout, json.dumps(dump_type(fb.mss, typeid, follow_types), indent=2) |
def mqlreaditer(self, sq, asof=None): | def mqlreaditer(self, sq, asof=None, headers=None): | def mqlreaditer(self, sq, asof=None): """read a structure query.""" cursor = True service = '/api/service/mqlread' if isinstance(sq, (tuple, list)): if len(sq) > 1: raise MetawebError("You cannot ask mqlreaditer a query in the form: [{}, {}, ...], just [{}] or {}") sq = sq[0] while 1: subq = dict(query=[sq], cursor=... |
r = self._httpreq_json(service, 'POST', form=dict(query=qstr)) | r = self._httpreq_json(service, 'POST', form=dict(query=qstr), headers=headers) | def mqlreaditer(self, sq, asof=None): """read a structure query.""" cursor = True service = '/api/service/mqlread' if isinstance(sq, (tuple, list)): if len(sq) > 1: raise MetawebError("You cannot ask mqlreaditer a query in the form: [{}, {}, ...], just [{}] or {}") sq = sq[0] while 1: subq = dict(query=[sq], cursor=... |
def mqlread(self, sq, asof=None): | def mqlread(self, sq, asof=None, headers=None): | def mqlread(self, sq, asof=None): """read a structure query. For a more complete description, see http://www.freebase.com/view/en/api_service_mqlread""" subq = dict(query=sq, escape=False) if asof: subq['as_of_time'] = asof if isinstance(sq, list): subq['cursor'] = True service = '/api/service/mqlread' self.log.info... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.