rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
security.declareProtected(permissions.View, 'post_validate') | security.declareProtected(CMFCorePermissions.View, 'post_validate') | def pre_validate(self, REQUEST=None, errors=None): pass |
security.declareProtected(permissions.View, 'validate') | security.declareProtected(CMFCorePermissions.View, 'validate') | def post_validate(self, REQUEST=None, errors=None): pass |
security.declareProtected(permissions.View, 'SearchableText') | security.declareProtected(CMFCorePermissions.View, 'SearchableText') | def validate(self, REQUEST=None, errors=None, data=None, metadata=None): """Validates the form data from the request. """ if errors is None: errors = {} self.pre_validate(REQUEST, errors) if errors: return errors self.Schema().validate(instance=self, REQUEST=REQUEST, errors=errors, data=data, metadata=metadata) self.po... |
except (ConflictError, KeyboardInterrupt): | except ConflictError: | def SearchableText(self): """All fields marked as 'searchable' are concatenated together here for indexing purpose. """ data = [] charset = self.getCharset() for field in self.Schema().fields(): if not field.searchable: continue method = field.getIndexAccessor(self) try: datum = method(mimetype="text/plain") except Ty... |
security.declareProtected(permissions.View, 'getCharset') | security.declareProtected(CMFCorePermissions.View, 'getCharset') | def SearchableText(self): """All fields marked as 'searchable' are concatenated together here for indexing purpose. """ data = [] charset = self.getCharset() for field in self.Schema().fields(): if not field.searchable: continue method = field.getIndexAccessor(self) try: datum = method(mimetype="text/plain") except Ty... |
security.declareProtected(permissions.View, 'get_size') | security.declareProtected(CMFCorePermissions.View, 'get_size') | def getCharset(self): """Returns the site default charset, or utf-8. """ properties = getToolByName(self, 'portal_properties', None) if properties is not None: site_properties = getattr(properties, 'site_properties', None) if site_properties is not None: return site_properties.getProperty('default_charset') return 'utf... |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def _processForm(self, data=1, metadata=None, REQUEST=None, values=None): request = REQUEST or self.REQUEST if values: form = values else: form = request.form fieldset = form.get('fieldset', None) schema = self.Schema() schemata = self.Schemata() fields = [] |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def at_post_edit_script(self): pass |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def markCreationFlag(self): """Sets flag on the instance to indicate that the object hasn't been saved properly (unset in content_edit). |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def unmarkCreationFlag(self): """Removes the creation flag. """ if shasattr(aq_inner(self), '_at_creation_flag'): self._at_creation_flag = False |
security.declareProtected(permissions.View, 'Schemata') | security.declareProtected(CMFCorePermissions.View, 'Schemata') | def _isIDAutoGenerated(self, id): """Avoid busting setDefaults if we don't have a proper acquisition context. """ plone_tool = getToolByName(self, 'plone_utils', None) if plone_tool is not None and \ shasattr(plone_tool, 'isIDAutoGenerated'): return plone_tool.isIDAutoGenerated(id) # Plone 2.0 compatibility script = ge... |
def Schema(self): """Return a (wrapped) schema instance for this object instance. """ schema = self.schema return ImplicitAcquisitionWrapper(schema, self) | def Schemata(self): """Returns the Schemata for the Object. """ return getSchemata(self) | |
except (ConflictError, KeyboardInterrupt): | except ConflictError: | def _migrateGetValue(self, name, new_schema=None): """Try to get a value from an object using a variety of methods.""" schema = self.Schema() # Migrate pre-AT 1.3 schemas. schema = fixSchema(schema) # First see if the new field name is managed by the current schema field = schema.get(getattr(new_schema.get(name,None),'... |
except (ConflictError, KeyboardInterrupt): | except ConflictError: | def _migrateSetValue(self, name, value, old_schema=None, **kw): """Try to set an object value using a variety of methods.""" schema = self.Schema() # Migrate pre-AT 1.3 schemas. schema = fixSchema(schema) field = schema.get(name, None) # Try using the field's mutator if field: mutator = field.getMutator(self) if mutato... |
security.declareProtected(permissions.View, 'isTemporary') | security.declareProtected(CMFCorePermissions.View, 'isTemporary') | def _migrateSetValue(self, name, value, old_schema=None, **kw): """Try to set an object value using a variety of methods.""" schema = self.Schema() # Migrate pre-AT 1.3 schemas. schema = fixSchema(schema) field = schema.get(name, None) # Try using the field's mutator if field: mutator = field.getMutator(self) if mutato... |
security.declareProtected(permissions.View, | security.declareProtected(CMFCorePermissions.View, | def isTemporary(self): """Checks to see if we are created as temporary object by portal factory. """ parent = aq_parent(aq_inner(self)) return shasattr(parent, 'meta_type') and \ parent.meta_type == 'TempFolder' |
security.declareProtected(permissions.ModifyPortalContent, | security.declareProtected(CMFCorePermissions.ModifyPortalContent, | def getFolderWhenPortalFactory(self): """Returns the folder where this object was created temporarily. """ ctx = aq_inner(self) if not ctx.isTemporary(): # Not a temporary object! return aq_parent(ctx) utool = getToolByName(self, 'portal_url') portal_object = utool.getPortalObject() |
security.declareProtected(permissions.View, 'getSubObject') | security.declareProtected(CMFCorePermissions.View, 'getSubObject') | def addSubObjects(self, objects, REQUEST=None): """Adds a dictionary of objects to a volatile attribute. """ if objects: storage = getattr(aq_base(self), '_v_at_subobjects', None) if storage is None: setattr(self, '_v_at_subobjects', {}) storage = getattr(aq_base(self), '_v_at_subobjects') for name, obj in objects.item... |
def handleEvents(ob, event): """Event subscriber for IBaseObject events. """ if IObjectWillBeAddedEvent.providedBy(event): if event.newParent is not None: ob.initializeLayers(ob, event.newParent) elif IObjectWillBeRemovedEvent.providedBy(event): if event.oldParent is not None: ob.cleanupLayers(ob, event.oldParent) | def handleEvents(ob, event): """Event subscriber for IBaseObject events. """ if IObjectWillBeAddedEvent.providedBy(event): if event.newParent is not None: ob.initializeLayers(ob, event.newParent) elif IObjectWillBeRemovedEvent.providedBy(event): if event.oldParent is not None: ob.cleanupLayers(ob, event.oldParent) | |
qi.reinstallProducts(product) | qi.reinstallProducts([product]) | def reinstallArchetypes(portal, out): """let's quickinstaller (re)install Archetypes and it's dependencies """ qi = getToolByName(portal, 'portal_quickinstaller') products = ('MimetypesRegistry', 'PortalTransforms', 'Archetypes', ) print >>out, 'Reinstalling Archetypes and it\'s dependencies' for product in products: i... |
qi.installProducts(product) | qi.installProducts([product]) | def reinstallArchetypes(portal, out): """let's quickinstaller (re)install Archetypes and it's dependencies """ qi = getToolByName(portal, 'portal_quickinstaller') products = ('MimetypesRegistry', 'PortalTransforms', 'Archetypes', ) print >>out, 'Reinstalling Archetypes and it\'s dependencies' for product in products: i... |
return self.EffectiveDate() | return self.EffectiveDate() or FLOOR_DATE | def effective( self ): """ Dublin Core element - date resource becomes effective, returned as DateTime. """ return self.EffectiveDate() |
return self.ExpirationDate() | return self.ExpirationDate() or CEILING_DATE | def expires( self ): """ Dublin Core element - date resource expires, returned as DateTime. """ return self.ExpirationDate() |
if kwargs.get('unwrapped', 0): return image return image.__of__(instance) | if hasattr(image, '__of__') and not kwargs.get('unwrapped', 0): return image.__of__(instance) return image | def get(self, instance, **kwargs): image = ObjectField.get(self, instance, **kwargs) if kwargs.get('unwrapped', 0): return image return image.__of__(instance) |
'action': 'base_view', | 'action': 'string:${object_url}/base_view', | def getCMFVersion(): from os.path import join from Globals import package_home from Products.CMFCore import cmfcore_globals |
'action': 'base_edit', | 'action': 'string:${object_url}/base_edit', | def getCMFVersion(): from os.path import join from Globals import package_home from Products.CMFCore import cmfcore_globals |
'action': 'base_metadata', | 'action': 'string:${object_url}/base_metadata', | def getCMFVersion(): from os.path import join from Globals import package_home from Products.CMFCore import cmfcore_globals |
'action': 'reference_edit', | 'action': 'string:${object_url}/reference_edit', | def getCMFVersion(): from os.path import join from Globals import package_home from Products.CMFCore import cmfcore_globals |
class TTWSchema(SimpleItem): def __init__(self, oid, text=None): self.id = oid self.text = text if text: self.compileSchema(text) def compileSchema(self, text): """Take the text of a schema and produce a field list by evaling in a preped namespace""" ns = {} import BaseContent import ExtensibleMetadata exec "from P... | def getType(name): return _types[name] | |
meta_types = all_meta_types = (( { 'name' : 'Schema', 'action' : 'manage_addSchemaForm'}, )) | meta_types = all_meta_types = () | def __call__(self): __traceback_info__ = self._args return renderer.render(**self._args) |
(Folder.manage_options[0],) + | def __call__(self): __traceback_info__ = self._args return renderer.render(**self._args) | |
{ 'label' : 'Types', 'action' : 'manage_debugForm', }, | { 'label' : 'UIDs', 'action' : 'manage_uids', }, | def __call__(self): __traceback_info__ = self._args return renderer.render(**self._args) |
{ 'label' : 'UIDs', 'action' : 'manage_uids', }, { 'label' : 'Catalogs', 'action' : 'manage_catalogs', }, | def __call__(self): __traceback_info__ = self._args return renderer.render(**self._args) | |
manage_addSchemaForm = PageTemplateFile('addSchema', _www) | def __call__(self): __traceback_info__ = self._args return renderer.render(**self._args) | |
self._templates[k] = v | self.bindTemplate(k, v) | def manage_templates(self, REQUEST=None): """set all the template/type mappings""" prefix = 'template_names_' for key in REQUEST.form.keys(): if key.startswith(prefix): k = key[len(prefix):] v = REQUEST.form.get(key) self._templates[k] = v |
def manage_addSchema(self, id, schema, REQUEST=None): """add a schema to the generator tool""" schema = schema.replace('\r', '') if not self._schemas.has_key(id): s = TTWSchema(id, schema) self._schemas[id] = s portal_types = getToolByName(self, 'portal_types') s.register(portal_types) if REQUEST: return REQUEST.RESP... | def manage_addSchema(self, id, schema, REQUEST=None): """add a schema to the generator tool""" schema = schema.replace('\r', '') | |
raise ValueError('No such content type: %s' % type_name) | raise ValueError('No such content type: %s' % typeid) | def allowedTypesReadable(self, instance): """Returns a dictionary that maps portal_type to its human readable form.""" tool = getToolByName(instance, 'portal_types') if tool is None: msg = "Couldn't get portal_types tool from this context" raise AttributeError(msg) |
or method == 'POST' and not isinstance(response, xmlrpc.Response) | or method == 'POST' and not isinstance(RESPONSE, xmlrpc.Response) | def __bobo_traverse__(self, REQUEST, name, RESPONSE=None): """ transparent access to session subobjects """ # is it a registered sub object data = self.getSubObject(name, REQUEST, RESPONSE) if data is not None: return data # or a standard attribute (maybe acquired...) # DM 2004-08-10: this breaks FTP/WebDAV's PUT: # I... |
log('NO PATH FROM' % (orig_mt, target_mimetype, path)) | log('NO PATH FROM %s TO %s : %s' % (orig_mt, target_mimetype, path)) | def convertTo(self, target_mimetype, orig, data=None, **kwargs): """Convert orig to a given mimetype""" if not data: data = self._wrap(target_mimetype) |
otherwise, set to true. | otherwise, set to true.""" | def set(self, instance, value, **kwargs): """If value is not defined or equal to 0, set field to false; otherwise, set to true. if not value or value == '0': value = None ## False else: value = 1 |
return purl.getRelativeUrl(aq_parent(instance)) | return '.' | def getDestination(self, instance): purl = getToolByName(instance, 'portal_url') if not self.destination: return purl.getRelativeUrl(aq_parent(instance)) else: value = getattr(aq_base(instance), self.destination, self.destination) if callable(value): value = value() |
return | raise AttributeError(name) | def __bobo_traverse__(self, REQUEST, name, RESPONSE=None): """ transparent access to session subobjects """ # is it a registered sub object data = self.getSubObject(name, REQUEST, RESPONSE) if data is not None: return data # or a standard attribute (maybe acquired...) # DM 2004-08-10: this breaks FTP/WebDAV's PUT: # I... |
tt = getToolByName(self, "portal_types") def isRegistered(type, tt=tt): return tt.getTypeInfo(type['portal_type']) != None | def listRegisteredTypes(self, inProject=None): """Return the list of sorted types""" tt = getToolByName(self, "portal_types") def isRegistered(type, tt=tt): return tt.getTypeInfo(type['portal_type']) != None | |
values = [v for v in values if isRegistered(v)] | tt = getToolByName(self, "portal_types") meta_types= tt.listContentTypes(self, by_metatype=True) values = [v for v in values if v['portal_type'] in meta_types] | def type_sort(a, b): v = cmp(a['package'], b['package']) if v != False: return v c = cmp(a['klass'].__class__.__name__, b['klass'].__class__.__name__) |
field.set(instance, v, **kwargs) | mutator = getattr(instance, field.mutator, None) if mutator is not None: mutator(v) | def demarshall(self, instance, data, **kwargs): from Products.CMFDefault.utils import parseHeadersBody headers, body = parseHeadersBody(data) for k, v in headers.items(): field = instance.getField(k) if field is not None: field.set(instance, v, **kwargs) content_type = headers.get('Content-Type', 'text/plain') kwargs.u... |
p.set(instance, body, **kwargs) | mutator = getattr(instance, p.mutator, None) if mutator is not None: mutator(body, **kwargs) | def demarshall(self, instance, data, **kwargs): from Products.CMFDefault.utils import parseHeadersBody headers, body = parseHeadersBody(data) for k, v in headers.items(): field = instance.getField(k) if field is not None: field.set(instance, v, **kwargs) content_type = headers.get('Content-Type', 'text/plain') kwargs.u... |
data = '%s\n%s' % (header, body) | data = '%s\n\n%s' % (header, body) | def marshall(self, instance, **kwargs): from Products.CMFDefault.utils import formatRFC822Headers p = instance.getPrimaryField() body = p.get(instance) content_type = length = None # Gather/Guess content type if IBaseUnit.isImplementedBy(body): content_type = str(body.getContentType()) body = body.getRaw() |
zLOG.LOG('ArchetypesTool', zLOG.WARNING, ('Trying to register "%s" which ' 'has already been registered. The new type %s ' 'is going to override %s') % (key, override_name, existing_name)) | log('ArchetypesTool: Trying to register "%s" which ' \ 'has already been registered. The new type %s ' \ 'is going to override %s' % (key, override_name, existing_name)) | def registerType(klass, package=None): if not package: package = _guessPackage(klass.__module__) ## registering a class results in classgen doing its thing ## Set up accessor/mutators and sane meta/portal_type generateClass(klass) data = { 'klass' : klass, 'name' : klass.__name__, 'identifier': klass.meta_type.capit... |
pc_brains = pc(path=abs_paths.keys()) | pc_brains = pc(path=abs_paths.keys(), **skw) | def assign(x, y): abs_paths[x]=y |
('targetId', 'FieldIndex'), ('targetTitle', 'FieldIndex'), | def install_referenceCatalog(self, out): if not hasattr(self, REFERENCE_CATALOG): #Add a zcatalog for uids addCatalog = manage_addReferenceCatalog addCatalog(self, REFERENCE_CATALOG, 'Archetypes Reference Catalog') catalog = getToolByName(self, REFERENCE_CATALOG) schema = catalog.schema() for indexName, indexType in ( ... | |
print "HIT" | def _getSchema(self): """return the schema associated with this instance""" # PHASE: Collect # using the policy schemaSources = self._schemaPolicy.collect(self) ### XXX Each axis should hand back a token that we can ## resubmit to validate our cache, but I will punt now ## and do full composite. Fake something for now ... | |
elif answer == "none": print "all channels skipped." break | def runConfigure(userConfig,all_channels): print "writing config file: "+userConfig try: userConfig_file = open(userConfig, 'w') for channel_id in all_channels.keys(): print "add channel "+all_channels[channel_id]+"? [yes,no,all,none (default=yes)]" answer = sys.stdin.readline() answer = re.sub("\n$","",answer) ... | |
self.von = httpfile | self.von = von | def __init__(self, link, httpfile, von): self.link = link self.httpfile = httpfile self.von = httpfile |
"""Return the named object, or the value of the default argument if given and the named object is not found. If no default is given and the object is not found a ``KeyError`` is raised. | """Return the named object, or raise ``KeyError`` if the object is not found. | def __getitem__(self, name): """Return the named object, or the value of the default argument if given and the named object is not found. If no default is given and the object is not found a ``KeyError`` is raised. """ return self.data[name] |
argument if given and the named object is not found. If no `default` is given and the object is not found a ``KeyError`` is raised. | argument if the object is not found. | def get(self, name, default=None): """Return the named object, or the value of the `default` argument if given and the named object is not found. If no `default` is given and the object is not found a ``KeyError`` is raised. """ return self.data.get(name, default) |
self.logger.warning("Error, reception of unexpected SUGGEST message from peer '%s':\n%s != %s" % (str(args.id_), self.jump_near_address.ToString(), args.address.ToString())) | self.logger.warning("Error, reception of unexpected SUGGEST message from peer '%s' at address '%s'" % (str(args.id_), args.address.ToString())) | def peer_SUGGEST(self, args): """ A peer answers a position suggestion in response to a JUMPNEAR message. """ # Instantiate the target peer if self.jump_near_address is None or self.jump_near_address != args.address: self.logger.warning("Error, reception of unexpected SUGGEST message from peer '%s':\n%s != %s" % (str(a... |
self.server.start_listening() | def start_listening(self): """launching main server listening to well-known port""" # delegate to ProfileServerFactory #self.server.start_listening() | |
self.label_conntype = wx.StaticText(self, -1, _("label_conntype")) | self.label_conntype = wx.StaticText(self, -1, "") | def __init__(self, config_data, *args, **kwds): self.config_data = config_data |
self.future_position = None | def MoveTo(self, (x, y, z)): """ Move to a given absolute position in the world. """ # Change position x %= self.world_size y %= self.world_size position = Position((x, y, z)) old_position = self.node.position | |
self.radio_btn_remote.SetValue(False) | if event.IsChecked(): self.radio_btn_remote.SetValue(False) | def OnRadioLocal(self, event): # wxGlade: ConnectionTypeDialog.<event_handler> self.radio_btn_remote.SetValue(False) self._UpdateUI() |
self.radio_btn_local.SetValue(False) | if event.IsChecked(): self.radio_btn_local.SetValue(False) | def OnRadioRemote(self, event): # wxGlade: ConnectionTypeDialog.<event_handler> self.radio_btn_local.SetValue(False) self._UpdateUI() |
def _clicked(evt): plugin.DoAction() | def _clicked(evt, p=plugin): if id_ is not None: p.DoPointToPointAction(self.peers[id_]) else: p.DoAction() | def _clicked(evt): plugin.DoAction() |
discovery_deferred.callback((self.host, self.port)) | discovery_deferred.callback(node.address) | def _found_private_addr(address): host, port = address if host != self.host or port != self.port: node.address.private_host = host node.address.private_port = port print "private address is %s:%d" % (host, port) discovery_deferred.callback((self.host, self.port)) |
for ok, result in results: | for ok, address in results: | def _succeed(results): # Build the list of local addresses once they are known addresses = [] for ok, result in results: if ok: host, port = result addresses.append(Address(host, port)) for p in self.pool: self.reactor.callLater(0, p.Launch, bootup_addresses or addresses) # Send statistics if self.params.send_stats: ge... |
host, port = result addresses.append(Address(host, port)) | addresses.append(address) | def _succeed(results): # Build the list of local addresses once they are known addresses = [] for ok, result in results: if ok: host, port = result addresses.append(Address(host, port)) for p in self.pool: self.reactor.callLater(0, p.Launch, bootup_addresses or addresses) # Send statistics if self.params.send_stats: ge... |
self.tree_list.SetItemText(child, container_path, FULL_PATH_COL) | self.tree_list.SetItemText(child, unicode(container_path, ENCODING), FULL_PATH_COL) | def _add_item_in_tree(self, parent, container): """add items in tree""" # create item container_path = container.get_path() if container.get_data() is None: name = os.path.basename(container_path) child = self.tree_list.AppendItem(parent, unicode(name, ENCODING)) container.set_data(child) self.tree_list.SetItemImage(ch... |
def add_file(self, path): | def add_file(self, value): | def add_file(self, path): """sets new value for repositor""" path = path.encode(ENCODING) return self._try_change(path, "add_file", "update_files") |
path = path.encode(ENCODING) return self._try_change(path, | return self._try_change(value, | def add_file(self, path): """sets new value for repositor""" path = path.encode(ENCODING) return self._try_change(path, "add_file", "update_files") |
def del_file(self, path): | def del_file(self, value): | def del_file(self, path): """sets new value for repositor""" path = path.encode(ENCODING) return self._try_change(path, "del_file", "update_files") |
path = path.encode(ENCODING) return self._try_change(path, | return self._try_change(value, | def del_file(self, path): """sets new value for repositor""" path = path.encode(ENCODING) return self._try_change(path, "del_file", "update_files") |
self.photo = "" | self.photo = QUESTION_MARK() | def __init__(self, name="cache"): AbstractDocument.__init__(self, name) self.title = u"" self.firstname = u"" self.lastname = u"" self.pseudo = u"" self.photo = "" self.email = u"" self.birthday = time.localtime() self.language = u"" self.address = u"" self.postcode = 0 self.city = u"" self.country = u"" self.descripti... |
return unicode(self.config.get(SECTION_PERSONAL, "photo"), self.encoding) except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): return QUESTION_MARK() | photo = unicode(self.config.get(SECTION_PERSONAL, "photo"), self.encoding) if not os.path.exists(photo): photo = QUESTION_MARK() except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): photo = QUESTION_MARK() return photo | def get_photo(self): """returns value of photo""" try: return unicode(self.config.get(SECTION_PERSONAL, "photo"), self.encoding) except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): return QUESTION_MARK() |
return str(wx.Locale.GetSystemEncodingName()) | return str(wx.Locale.GetSystemEncodingName()) or "utf-8" | def GetCharset(): """ Get the name of the current charset. """ return str(wx.Locale.GetSystemEncodingName()) |
self.panel_identities.Show(show=False) | self.panel_identities.Show(show=self.config_data.multiple_identities) | def __set_properties(self): # begin wxGlade: ConnectDialog.__set_properties self.SetTitle(_("Connect to Solipsis")) self.text_ctrl_pseudo.SetFocus() self.button_ok.SetDefault() # end wxGlade # So that self.GetBestVirtualSize() works properly when identities are disabled self.panel_identities.Show(show=False) |
print "sending", message | print "sending UDP:", message | def make_message(command, host, port, data=''): """format message to be sent via service_api""" message = "%s %s:%d %s"% (command, host, port, data) print "sending", message return message |
remote_ip, port = parse_address(service.address) print "*****", remote_ip, port self._init_peer(peer.id_, remote_ip) | def on_new_peer(self, peer, service): """tries to connect to new peer""" # parse address, remote_ip, port = parse_address(service.address) print "*****", remote_ip, port # set up information in cache self._init_peer(peer.id_, remote_ip) # declare known port to other peer throug service_api message = make_message(MESSAG... | |
message = make_message(MESSAGE_HELLO, self.host, self.port) self.service_api.SendData(peer.id_, message) | if not self.remote_ips.has_key(peer.id_): message = make_message(MESSAGE_HELLO, self.host, self.port) self.service_api.SendData(peer.id_, message) def on_lost_peer(self, peer_id): """tries to connect to new peer""" if self.remote_ips.has_key(peer_id): remote_ip = self.remote_ips[peer_id] if self.remote_ids.has_key(r... | def on_new_peer(self, peer, service): """tries to connect to new peer""" # parse address, remote_ip, port = parse_address(service.address) print "*****", remote_ip, port # set up information in cache self._init_peer(peer.id_, remote_ip) # declare known port to other peer throug service_api message = make_message(MESSAG... |
def on_lost_peer(self, peer_id): """tries to connect to new peer""" self.server.lose_local_server(self.remote_ips[peer_id]) self.client.lose_dedicated_client(self.remote_ips[peer_id]) del self.remote_ips[peer_id] def on_change_peer(self, peer, service): """tries to connect to new peer""" r_ip, r_port = parse_addres... | def on_service_data(self, peer_id, message): | def on_lost_peer(self, peer_id): """tries to connect to new peer""" # TODO: do this cleanup after a TIMEOUT # close connections and clean server self.server.lose_local_server(self.remote_ips[peer_id]) self.client.lose_dedicated_client(self.remote_ips[peer_id]) # clean cache del self.remote_ips[peer_id] |
print "Received", data | def on_service_data(self, peer_id, data): """demand to establish connection from peer that failed to connect through TCP""" try: print "Received", data # parse message command, r_ip, r_port, data = parse_message(data) # create client if necessary if not self.remote_ips.has_key(peer_id): self._init_peer(peer_id, r_ip) #... | |
command, r_ip, r_port, data = parse_message(data) | command, r_ip, r_port, data = parse_message(message) | def on_service_data(self, peer_id, data): """demand to establish connection from peer that failed to connect through TCP""" try: print "Received", data # parse message command, r_ip, r_port, data = parse_message(data) # create client if necessary if not self.remote_ips.has_key(peer_id): self._init_peer(peer_id, r_ip) #... |
self._init_peer(peer_id, r_ip) assert r_ip == self.remote_ips[peer_id], \ "incoherent ip %s instead of %s"\ % (r_ip, self.remote_ips[peer_id]) | self.remote_ips[peer_id] = r_ip self.remote_ids[r_ip] = peer_id print "received UDP from new peer [%s]:"% r_ip, message else: print "received UDP from %s:"% self.remote_ips[peer_id], message assert r_ip == self.remote_ips[peer_id], \ "incoherent ip: message indicates %s instead of %s"\ % (r_ip, self.remote_ips[peer_id]... | def on_service_data(self, peer_id, data): """demand to establish connection from peer that failed to connect through TCP""" try: print "Received", data # parse message command, r_ip, r_port, data = parse_message(data) # create client if necessary if not self.remote_ips.has_key(peer_id): self._init_peer(peer_id, r_ip) #... |
print "Cl.Manager received", line | print "Client Manager received from %s:"% self.transport.getPeer().host, line | def lineReceived(self, line): """incomming connection from other peer""" print "Cl.Manager received", line # on greeting, stores info about remote host (profile id) if line.startswith(SERVER_SEND_ID): # get remote information remote_host, remote_port = parse_address(line[len(SERVER_SEND_ID):]) # store remote informatio... |
print "Svr.Manager received", line | print "Server Manager received from %s"% self.transport.getPeer().host, line | def lineReceived(self, line): """incomming connection from other peer""" print "Svr.Manager received", line |
print "client received", line | print "client received fom %s"% self.transport.getPeer().host, line | def lineReceived(self, line): """Override this for when each line is received.""" print "client received", line # UPLOAD # FIXME factorize with server if line.startswith(ASK_UPLOAD_FILES): file_name = line[len(ASK_UPLOAD_FILES)+1:].strip() file_desc = self.factory.manager.facade.\ get_file_container(file_name) # check ... |
print "server received", line | print "server received from %s"% self.transport.getPeer().host, line | def lineReceived(self, line): """Override this for when each line is received.""" print "server received", line # donwnload file if line.startswith(ASK_DOWNLOAD_FILES): file_name = line[len(ASK_DOWNLOAD_FILES)+1:].strip() file_desc = self.factory.manager.facade.\ get_file_container(file_name) # check shared if file_des... |
item = wx.MenuItem(menu, item_id, title.encode(self.charset)) | item = wx.MenuItem(menu, item_id, title) | def GetPopupMenuItems(self, menu, peer_id): """ Get specific service items for the UI pop-up menu. """ l = [] self.action_ids.Begin() # Get menu elements for each service plug-in for service_id in self._Services(): plugin = self.plugins[service_id] if peer_id is not None and peer_id in self.peers: if self.peers[peer_id... |
self.context.addGlobal("pseudo", desc.pseudo) | self.context.addGlobal("pseudo", unicode(desc.pseudo, ENCODING)) | def __init__(self, desc, html_window=None, auto_refresh=False, do_import=True, name="html"): # init HTML string, wxWidget self.view = None self.auto_refresh = auto_refresh self.html_window = html_window and UIProxy(html_window) or None # Create the context that is used by the template self.context = simpleTALES.Context... |
def GetPopupMenuItems(self, menu, id_): | def GetPopupMenuItems(self, menu, peer_id): | def GetPopupMenuItems(self, menu, id_): """ Get specific service items for the UI pop-up menu. """ l = [] self.action_ids.Begin() for service_id in self._Services(): plugin = self.plugins[service_id] if id_ is not None: if self.peers[id_].GetService(service_id) is not None: titles = plugin.GetPointToPointActions() else... |
if id_ is not None: if self.peers[id_].GetService(service_id) is not None: | if peer_id is not None and peer_id in self.peers: if self.peers[peer_id].GetService(service_id) is not None: | def GetPopupMenuItems(self, menu, id_): """ Get specific service items for the UI pop-up menu. """ l = [] self.action_ids.Begin() for service_id in self._Services(): plugin = self.plugins[service_id] if id_ is not None: if self.peers[id_].GetService(service_id) is not None: titles = plugin.GetPointToPointActions() else... |
self.factory.manager.download_dlg.update_download(self.size) | self.factory.manager.update_download(self.size) | def rawDataReceived(self, data): """specialised in Client/Server protocol""" self.size += len(data) self.factory.manager.download_dlg.update_download(self.size) |
self.factory.manager.download_dlg.update_file( file_path[-1], size) | self.factory.manager.update_file(file_path[-1], size) | def connectionMade(self): """after ip is checked, begin connection""" PeerProtocol.connectionMade(self) # check action to be made if self.factory.download.startswith(ASK_DOWNLOAD_FILES): if self.factory.files: self.setRawMode() # TODO: check place where to download and non overwriting # create file file_path, size = se... |
self.manager.download_dlg.update_file(self.split_path, self.size) | self.manager.update_file(self.split_path, self.size) | def get_message(self): """format message to send to client according to file to be uploaded""" if self.message == MESSAGE_PROFILE: self.file = tempfile.NamedTemporaryFile() message = ASK_UPLOAD_PROFILE elif self.message == MESSAGE_BLOG: self.file = StringIO() message = ASK_UPLOAD_BLOG elif self.message == MESSAGE_SHARE... |
return [sys.executable, prog_path] | return [sys.executable, "'" + prog_path + "'"] | def python_args(self): # Find the proper executable in the current dir for f in self.launcher_alternatives: if os.path.isfile(f): prog_name = f break else: return None prog_path = abspath(prog_name) # We try to keep the same Python interpreter as currently if os.path.exists(sys.executable) and re.match(r'.*\.py[cow]?$'... |
return [prog_path] | return ["'" + prog_path+ "'"] | def python_args(self): # Find the proper executable in the current dir for f in self.launcher_alternatives: if os.path.isfile(f): prog_name = f break else: return None prog_path = abspath(prog_name) # We try to keep the same Python interpreter as currently if os.path.exists(sys.executable) and re.match(r'.*\.py[cow]?$'... |
if isinstance(address, Address): host, port = (address.host, address.port) else: host, port = address | our_address = self.node.address if address.host == our_address.host and \ address.private_host is not None and our_address.private_host is not None: host, port = address.private_host, address.private_port else: host, port = address.host, address.port | def _SendData(self, address, data, log=True): """ Send raw data to a destination address, and optionally log it. """ if isinstance(address, Address): host, port = (address.host, address.port) else: host, port = address self.node_protocol.SendData((host, port), data) if log: self.logger.debug(">>>> sending to %s:%d\n%s"... |
try: pickle.dump(d, outfile, protocol=-1) except TypeError: pickle.dump(d, outfile, proto=-1) | pickle.dump(d, outfile, -1) | def Save(self, outfile): """ Store configuration in a writable file object. """ d = self.GetDict() # Python < 2.4 compatibility: the "protocol" argument used to be name "proto"... try: pickle.dump(d, outfile, protocol=-1) except TypeError: pickle.dump(d, outfile, proto=-1) |
self.getfile_item = wx.MenuItem(self.action_menu, wx.NewId(), _("Get files"), "", wx.ITEM_NORMAL) | self.getfile_item = wx.MenuItem(self.action_menu, wx.NewId(), _("&Get files\\Ctrl+G"), "", wx.ITEM_NORMAL) | def __init__(self, options, parent, id, plugin=None, **kwds): UIProxyReceiver.__init__(self) self.plugin = plugin self.options = options args = (parent, id) # begin wxGlade: MatchFrame.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) # Menu Bar self.match_frame_menubar = wx.MenuBa... |
self.host = host or "bots.netofpeers.net" | self.host = host or "localhost" | def __init__(self, host=None, port=None, pseudo=None): ManagedData.__init__(self) # Initialize all values self.pseudo = pseudo or u"Guest" self.host = host or "bots.netofpeers.net" self.port = port or 8550 self.always_try_without_proxy = True self.proxymode_auto = True self.proxymode_manual = False self.proxymode_none ... |
self.host = socket.gethostbyname(socket.gethostname()) self.port = random.randrange(7000, 7100) | def Init(self): self.reactor = self.service_api.GetReactor() # TODO: smartly discover our own address IP # (this is where duplicated code starts to appear...) self.host = socket.gethostbyname(socket.gethostname()) self.port = random.randrange(7000, 7100) self.hosts = {} self.str_action = _("Chat with all peers") self.n... | |
service.address = "%s:%d" % (self.host, self.port) | service.address = "127.0.0.1:9999" | def DescribeService(self, service): service.address = "%s:%d" % (self.host, self.port) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.