rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
init_properties() | def register(): init_properties() bpy.types.VIEW3D_PT_view3d_meshdisplay.append(menu_func) | |
if False: | if True: | def register(): if False: for op in object_ops: bpy.types.unregister(op) for op in pose_ops: bpy.types.unregister(op) for op in object_ops: bpy.types.register(op) for op in pose_ops: bpy.types.register(op) #bpy.types.unregister(VIEW3D_MT_copypopup) #bpy.types.unregister(VIEW3D_MT_posecopypopup) #bpy.types.register(V... |
km = bpy.context.manager.keyconfigs['Blender'].keymaps['Object Mode'] | km = bpy.context.window_manager.keyconfigs['Blender'].keymaps['Object Mode'] | def register(): if False: for op in object_ops: bpy.types.unregister(op) for op in pose_ops: bpy.types.unregister(op) for op in object_ops: bpy.types.register(op) for op in pose_ops: bpy.types.register(op) #bpy.types.unregister(VIEW3D_MT_copypopup) #bpy.types.unregister(VIEW3D_MT_posecopypopup) #bpy.types.register(V... |
km = bpy.context.manager.keyconfigs['Blender'].keymaps['Pose'] | km = bpy.context.window_manager.keyconfigs['Blender'].keymaps['Pose'] | def register(): if False: for op in object_ops: bpy.types.unregister(op) for op in pose_ops: bpy.types.unregister(op) for op in object_ops: bpy.types.register(op) for op in pose_ops: bpy.types.register(op) #bpy.types.unregister(VIEW3D_MT_copypopup) #bpy.types.unregister(VIEW3D_MT_posecopypopup) #bpy.types.register(V... |
for op in object_ops: bpy.types.unregister(op) for op in pose_ops: bpy.types.unregister(op) | def unregister(): for op in object_ops: bpy.types.unregister(op) for op in pose_ops: bpy.types.unregister(op) #bpy.types.unregister(VIEW3D_MT_copypopup) #bpy.types.unregister(VIEW3D_MT_posecopypopup) for item in bpy.context.manager.keyconfigs['Blender'].keymaps['Pose'].items: #print(dir(item)) if item.name == 'Call M... | |
for item in bpy.context.manager.keyconfigs['Blender'].keymaps['Pose'].items: | for item in bpy.context.window_manager.keyconfigs['Blender'].keymaps['Pose'].items: | def unregister(): for op in object_ops: bpy.types.unregister(op) for op in pose_ops: bpy.types.unregister(op) #bpy.types.unregister(VIEW3D_MT_copypopup) #bpy.types.unregister(VIEW3D_MT_posecopypopup) for item in bpy.context.manager.keyconfigs['Blender'].keymaps['Pose'].items: #print(dir(item)) if item.name == 'Call M... |
self.remotepath = remotepath | self.remotepath = remotepath.rstrip('/') | def __init__(self, remotepath): StaticDirect.__init__(self) self.remotepath = remotepath |
self.remotepath, rest.lstrip('/')) | self.remotepath, filepath.lstrip('/')) | def get(self, request, filepath): return '%s/%s' % ( self.remotepath, rest.lstrip('/')) |
def __init__(self, remotepath): | def __init__(self, remotepaths): | def __init__(self, remotepath): self.remotepaths = remotepaths |
CCLPageTemplateFile.pt_render(self, namespace, *args, **kwargs) | return CCLPageTemplateFile.pt_render(self, namespace, *args, **kwargs) | def pt_render(self, namespace, *args, **kwargs): ZPT_TEST_TEMPLATES[self.filename] = namespace CCLPageTemplateFile.pt_render(self, namespace, *args, **kwargs) |
def __call__(controller): | def __call__(self, controller): | def __call__(controller): def new_controller_func(request, *args, **kwargs): if request.method not in self.allowed_methods return HTTPMethodNotAllowed() |
if request.method not in self.allowed_methods | if request.method not in self.allowed_methods: | def new_controller_func(request, *args, **kwargs): if request.method not in self.allowed_methods return HTTPMethodNotAllowed() |
return self.__filter__(scans, **conditions) | return self.__filter__(expression=None, scans=scans, **conditions) | def __filter__(self, expression=None, scans=None, **conditions): if scans==None: scans = self.itervalues() if expression: scans = [scan for scan in self.itervalues() if eval(expression, dict(scan))] return self._list_from_scans(scans) try: field, condition = conditions.popitem() scans = [scan for scan in self.itervalue... |
author='Rui Guerra, kiorky', author_email='rui AT v2 DOT nl, kiorky <kiorky@cryptelium.net>', | author='Rui Guerra <rui@v2.nl>, kiorky <kiorky@cryptelium.net>', | def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() |
return Asset.objects(path=i).first() | return Asset.objects(path=value).first() | def native(self, value): from web.extras.contentment.components.asset.model import Asset value = super(AssetList, self).native(value) if value is None: return None return Asset.objects(path=i).first() |
node.path = '/' + '/'.join([i.name for i in node.parents] + [node.name]) | node.path = '/' + '/'.join([i.name for i in node.parents][1:] + [node.name]) | def attach(self, parent): if self.parent: self.parent.children.remove(self) self.parent.save() self.parent = parent self.parents = (parent.parents if parent.parents else []) + [parent] self.path = '/' + '/'.join([i.name for i in self.parents][1:] + [self.name]) self.save() if not parent.children: parent.children = ... |
return super(Asset, self).save(safe=safe, force_insert=force_insert, validate=validate) | result = super(Asset, self).save(safe=safe, force_insert=force_insert, validate=validate) if dirty and 'name' in dirty: log.debug("Re-naming asset %r...", self) self.path = '/' + '/'.join([i.name for i in self.parents][1:] + [self.name]) super(Asset, self).save(safe=safe, force_insert=force_insert, validate=validate)... | def save(self, safe=True, force_insert=False, validate=True, dirty=None): if not dirty: return super(Asset, self).save(safe=safe, force_insert=force_insert, validate=validate) self.reindex(dirty) return super(Asset, self).save(safe=safe, force_insert=force_insert, validate=validate) |
data['root'] = Asset.objects(path='/').first() | data['root'] = Asset.objects(path=None).first() | def inner(self, *args, **kw): if not authorized(self.asset): raise web.core.http.HTTPUnauthorized template = "json:" data = f(self, *args, **kw) if not isinstance(data, tuple): return data template, data = data if data is None: data = dict() data['root'] = Asset.objects(path='/').first() data['asset'] = self.asset... |
return Asset.objects(path='/').first() | return Asset.objects(path=None).first() | def asset(self): from web.extras.contentment.components.asset.model import Asset identifier = self._identifier try: if isinstance(identifier, Asset): return identifier elif identifier is not None: return Asset.objects.with_id(identifier) return Asset.objects(path='/').first() except: log.exception("Error loading mo... |
install_requires = ['WebCore', 'Mako', 'pymongo', 'mongoengine', 'marrow.util', 'textile', 'slate', 'pytz', 'pdfminer'], | install_requires = ['WebCore', 'beaker', 'mako', 'pymongo', 'mongoengine', 'marrow.util', 'textile', 'slate', 'pytz', 'pdfminer'], | def execfile(filename, globals_=None, locals_=None): if globals_ is None: globals_ = globals() if locals_ is None: locals_ = globals_ exec(compile(open(filename).read(), filename, 'exec'), globals_, locals_) |
client = get_client(client) client.delete(self.endpoint, id) | if client is None: client = get_client() client.delete(cls.endpoint, id) | def __class_delete(cls, id, client=None): """Deletes an object identified by `id`""" client = get_client(client) client.delete(self.endpoint, id) |
def __instance_delete(self, client=None): | def __instance_delete(self, obj, client=None): | def __instance_delete(self, client=None): # XXX: may need to change to self.__class__.delete(self.id, client) return self.__class_delete(self.id, client) |
if cls.parent_class and not getattr(self, cls.parent_id_attr, None): | if cls.parent_class and not getattr(cls, cls.parent_id_attr, None): | def all(cls, client): """Retrives all of the available objects""" if cls.parent_class and not getattr(self, cls.parent_id_attr, None): raise MissingParentDetails() endpoint = cls.endpoint if cls.parent_class: endpoint = "%s/%s/%s" % (cls.parent_class.endpoint, getattr(self, cls.parent_id_attr), cls.endpoint) data = cli... |
getattr(self, cls.parent_id_attr), | getattr(cls, cls.parent_id_attr), | def all(cls, client): """Retrives all of the available objects""" if cls.parent_class and not getattr(self, cls.parent_id_attr, None): raise MissingParentDetails() endpoint = cls.endpoint if cls.parent_class: endpoint = "%s/%s/%s" % (cls.parent_class.endpoint, getattr(self, cls.parent_id_attr), cls.endpoint) data = cli... |
def generate_signature(self, url, params=None): | def generate_signature(self, url, query_params=None, body_params=None): | def generate_signature(self, url, params=None): """Generates the appropriate signature given a url and optional params.""" sig = url if params: sig += self._flatten_params(params) sig += self.app_secret return hashlib.sha256(sig).hexdigest() |
if params: sig += self._flatten_params(params) | if query_params: sig += self._flatten_params(query_params) if body_params: sig += self._flatten_params(body_params) | def generate_signature(self, url, params=None): """Generates the appropriate signature given a url and optional params.""" sig = url if params: sig += self._flatten_params(params) sig += self.app_secret return hashlib.sha256(sig).hexdigest() |
get_keys = ['sig', 'time', 'format'] get_params = {} | query_keys = ['sig', 'time', 'format'] query_params = {} | def _sign_postish(self, url, params): """Used to sign post-like requests ("POST" and "PUT")""" # Split the parameters for use in the query string and the # request body if params is None: params = {} get_keys = ['sig', 'time', 'format'] get_params = {} body_params = {} for k, v in params.iteritems(): if k in get_keys: ... |
if k in get_keys: get_params[k] = v | if k in query_keys: query_params[k] = v | def _sign_postish(self, url, params): """Used to sign post-like requests ("POST" and "PUT")""" # Split the parameters for use in the query string and the # request body if params is None: params = {} get_keys = ['sig', 'time', 'format'] get_params = {} body_params = {} for k, v in params.iteritems(): if k in get_keys: ... |
if 'time' in get_params: body_params['time'] = get_params['time'] | if not 'time' in query_params and not 'time' in body_params: body_params['time'] = query_params['time'] = str(unix_time()) elif 'time' in query_params: body_params['time'] = query_params['time'] else: query_params['time'] = body_params['time'] | def _sign_postish(self, url, params): """Used to sign post-like requests ("POST" and "PUT")""" # Split the parameters for use in the query string and the # request body if params is None: params = {} get_keys = ['sig', 'time', 'format'] get_params = {} body_params = {} for k, v in params.iteritems(): if k in get_keys: ... |
body_params = self._sign_getish(url, body_params) get_params['sig'] = body_params['sig'] del body_params['sig'] return get_params, body_params | query_params['sig'] = self.generate_signature(url, query_params, body_params) return query_params, body_params | def _sign_postish(self, url, params): """Used to sign post-like requests ("POST" and "PUT")""" # Split the parameters for use in the query string and the # request body if params is None: params = {} get_keys = ['sig', 'time', 'format'] get_params = {} body_params = {} for k, v in params.iteritems(): if k in get_keys: ... |
body = urlencode(body_params) r = self.conn.post(url, payload=body, **get_params) | r = self.conn.post(url, payload=body_params, **get_params) | def post(self, endpoint, params=None): url = self._abs_from_rel(endpoint) get_params, body_params = self._sign_postish(url, params) body = urlencode(body_params) r = self.conn.post(url, payload=body, **get_params) return json.loads(r.body) |
return [cls(**i) for i in data] | return [cls(**clean_obj_keys(i)) for i in data[0]] | def all(cls, client=None): """Retrives all of the available objects""" client = get_client(client) if cls.parent_class and not getattr(self, cls.parent_id_attr, None): raise MissingParentDetails() endpoint = cls.endpoint if cls.parent_class: endpoint = "%s/%s/%s" % (cls.parent_class.endpoint, getattr(self, cls.parent_i... |
return cls(**data) | return cls(**clean_obj_keys(data[0])) | def get(cls, id, client=None): """Retrieves an object with the given `id`, using the `client` object if passed. """ client = get_client(client) data = client.get("%s/%s" % (cls.endpoint, id)) return cls(**data) |
): | **kw): | def __init__(self, id=None, pub_title=None, pub_description=None, end_user_title=None, end_user_description=None, created_timestamp=None, modified_timestamp=None, currency_type_id=None, exchange_rate=None, relative_weight=None, ): self.currency_type_id = currency_type_id self.exchange_rate = exchange_rate self.relative... |
created_timestamp, modified_timestamp) | created_timestamp, modified_timestamp, **kw) | def __init__(self, id=None, pub_title=None, pub_description=None, end_user_title=None, end_user_description=None, created_timestamp=None, modified_timestamp=None, currency_type_id=None, exchange_rate=None, relative_weight=None, ): self.currency_type_id = currency_type_id self.exchange_rate = exchange_rate self.relative... |
if color.find('gradient') == 0: | if color.find('gradient') == 0 or color.find('plasma') == 0: | def __init__(self, filename=None, color=None, *args, **kargs): if isinstance(filename, str): pgmagick.Image.__init__(self, filename) elif isinstance(filename, (list, tuple)): size = filename geometry = pgmagick.Geometry(int(size[0]), int(size[1])) if isinstance(color, (list, tuple)): r, g, b = int(color[0]), int(color[... |
return False | raise Exception(filename + " not found") | def find_file(filename, search_dirs): for dirname in search_dirs: for root, dirs, files in os.walk(dirname): for f in files: if filename in f: return dirname for d in dirs: if filename in d: return dirname if filename in root: return dirname return False |
size = pgmagick.Image.size(self) self.width, self.height = size.width(), size.height() | self.width, self.height = self.columns(), self.rows() | def __init__(self, filename=None, color=None, *args, **kargs): if type(filename) == str: pgmagick.Image.__init__(self, filename) elif type(filename) == list or type(filename) == tuple: size = filename geometry = pgmagick.Geometry(int(size[0]), int(size[1])) if type(color) == list or type(color) == tuple: r, g, b = int(... |
description="Yet Another Python wrapper for GraphicsMagick++", | description="Yet Another Python wrapper for GraphicsMagick", | def find_file(filename, search_dirs): for dirname in search_dirs: for root, dirs, files in os.walk(dirname): for f in files: if filename in f: return dirname for d in dirs: if filename in d: return dirname if filename in root: return dirname return False |
tn = self.getFile(c.thumbnail.text,tn) | try: tn = self.getFile(c.thumbnail.text,tn) except: tn = c.thumbnail.text | def CONTACTS(self,user='default'): contacts = self.api().GetFeed('/data/feed/api/user/%s/contacts?kind=user' % (user)) tot = int(contacts.total_results.text) for c in contacts.entry: tn = self.dataPath('cache/' + c.user.text + '.jpg') if not os.path.exists(tn): tn = self.getFile(c.thumbnail.text,tn) #tn = c.thumbnail.t... |
(repr(processSources.__name__), repr(e)) | (repr(processSources.__name__), repr(e))) | def _initFromDirectory(self,dirname): |
processData["store"] = process.storeSupported processData["status"] = process.statusSupported | if process.storeSupported == True: processData["store"] = 'true' else: processData["store"] = 'false' if process.statusSupported == True: processData["status"] = 'true' else: processData["status"] = 'false' | def processesDescription(self): """Format process description block |
formats=[{"mimeType":"image/tiff"}])) | formats=[{"mimeType":"image/tiff"}]) | def __init__(self): WPSProcess.__init__(self,identifier="complexRaster", title="Second Process") |
elif types.FileType == type(f) | elif types.FileType == type(f): | def printResponse(self,fileDes,isSoap=False,response=None): """ Print response to files given as input parameter. |
self._printResponseJava(f,,response) | self._printResponseJava(f,response) | def printResponse(self,fileDes,isSoap=False,response=None): """ Print response to files given as input parameter. |
def _printResponseModPython(request, response): | def _printResponseModPython(self, request, response): | def _printResponseModPython(request, response): |
def _printResponseFile(fileOut, response): | def _printResponseFile(self, fileOut, response): | def _printResponseFile(fileOut, response): |
def _printResponseJava(resp, response): | def _printResponseJava(self, resp, response): | def _printResponseJava(resp, response): resp.setContentType("text/xml") toClient = resp.getWriter() toClient.println(re.sub(EMPTYPARAMREGEX,"",response)) |
attributes["value"] = literalDataNode.firstChild.nodeValue | attributes["value"] = (literalDataNode.firstChild.nodeValue).encode("utf-8") | def parseLiteralData(self,literalDataNode): """Parse literal data node""" |
self.statusTime = time.time() | self.statusTime = time.localtime() | def __init__(self,wps, processes=None): |
self.statusTime = time.time() self.templateProcessor.set("statustime", time.ctime(self.statusTime)) | self.statusTime = time.localtime() self.templateProcessor.set("statustime", time.strftime('%Y-%m-%dT%H:%M:%SZ', self.statusTime)) | def promoteStatus(self,status, statusMessage=0, percent=0, exceptioncode=0, locator=0, output=None): """Sets status of currently performed Execute request |
inputUrl) | url) | def downloadData(self, url): """Download data from given url. Do not download more, then self.maxmegabites |
print "Content-type: text/xml\n\n" | print "Content-type: text/xml\n" | def __str__(self): |
elif os.name == "java" : | elif OSNAME == "java" : | def response(response,targets,isSoap=False,contentType="application/xml"): """ Print response to files given as input parameter. :param targets: file object or list of file objects. File name, mod_python request or java servlet response :type targets: string or list, :param isSoap: print the response in SOAP envelope ... |
WPSTree.setAttribute("version","1.0.0") | WPSTree.set("version","1.0.0") | def doFixTavernaBug(WPSTree): #Taverna hack until version 2.3 release #Check that the attributes are empy if not bool(WPSTree.attrib): WPSTree.set("service","WPS") tagNameRequest=WPSTree.tag.split("}")[1] #tagNameRequest=firstElement.tagName.split(":")[1] if tagNameRequest=="DescribeProcess" or tagNameRequest=="Execu... |
def doCleanBug5762(document): for node in doc_order_iter(document): attrMap=node.attributes try: for attrKey in attrMap.keys(): attr=attrMap[attrKey] if (type(attr.value)==types.NoneType or len(attr.value)==0): node.removeAttribute(attr.name) except: pass return document def doc_order_iter(node): """ Iterate... | def doFixTavernaBug(WPSTree): #Taverna hack until version 2.3 release #Check that the attributes are empy if not bool(WPSTree.attrib): WPSTree.set("service","WPS") tagNameRequest=WPSTree.tag.split("}")[1] #tagNameRequest=firstElement.tagName.split(":")[1] if tagNameRequest=="DescribeProcess" or tagNameRequest=="Execu... | |
Soap features, like authorization and so on. | Soap features, ralike authorization and so on. | def doFixTavernaBug(WPSTree): #Taverna hack until version 2.3 release #Check that the attributes are empy if not bool(WPSTree.attrib): WPSTree.set("service","WPS") tagNameRequest=WPSTree.tag.split("}")[1] #tagNameRequest=firstElement.tagName.split(":")[1] if tagNameRequest=="DescribeProcess" or tagNameRequest=="Execu... |
self.tree = etree.parse(StringIO.StringIO(unescape(document.toxml(),entities={""":"'"}))) except etree.XMLSyntaxError,e: | try: self.tree = etree.parse(StringIO.StringIO(unescape(document.toxml(),entities={""":"'"}))) except: document=doCleanBug5762(document) self.tree = etree.parse(StringIO.StringIO(unescape(document.toxml(),entities={""":"'"}))) except etree.XMLSyntaxError,e: | def __init__(self,document=None): if document: try: if type(input) == type(""): self.tree=etree.parse(StringIO.StringIO(unescape(document,entities={""":"'"}))) #<?xml version='1.0' encoding='UTF-8'?> will cause a crash #lxml.etree.XMLSyntaxError: XML declaration allowed only at the start of the document, line 1, c... |
if not self.wps.inputs["identifier"] in self.processes.__all__: | prc = self.wps.inputs["identifier"] if not prc in self.processes.__all__: | def __init__(self,wps): self.wps = wps |
"?service=WPS&request=DescribeProcess&version="+config.getConfigValue("wps","version")+\ "&identifier="+ process.identifier | "?service=WPS&request=DescribeProcess&version="+config.getConfigValue("wps","version")+\ "&identifier="+ process.identifier | def formatMetadata(self,process): """Create structure suitble for template form process.metadata |
except TemplateError,e: | except pywps.Template.TemplateError,e: | def __init__(self,wps,processes=None): """Class constructor""" self.wps = wps |
output.identifier+"-"+self.pid),"w") f.write(output.value) | "%s-%s" % (output.identifier,self.pid)),"w") f.write(str(output.value)) | def _asReferenceOutput(self,templateOutput, output): |
"/"+output.identifier+"-"+str(self.pid) | "/"+"%s-%s" % (output.identifier, self.pid) | def _asReferenceOutput(self,templateOutput, output): |
if type(identifieres) == type(""): identifieres = [identifieres] | if type(identifiers) == type(""): identifiers = [identifiers] | def checkProcess(self,identifiers): """check, if given identifiers are available as processes""" |
"""Allow traveral to @@<view>/tilename/tileid | """Allow traversal to @@<view>/tilename/tileid | def publishTraverse(self, request, name): """Allow traveral to @@<view>/tilename/tileid """ # 1. Look up the view, but keep this view as the traveral context in # anticipation of an id if self.view is None: tile_info = queryUtility(ITileType, name=name) if tile_info is None: raise KeyError(name) self.view = queryMult... |
self.assertEquals("<html><body><b>Transient tile Test message</b></body></html>", self.browser.contents) | self.failUnless("<b>Transient tile Test message</b>" in self.browser.contents) | def test_transient_lifecycle(self): # Log in self.browser.addHeader('Authorization', 'Basic %s:%s' % (ptc.default_user, ptc.default_password,)) # Add a new transient tile using the @@add-tile view self.browser.open(self.folder.absolute_url() + '/@@add-tile') self.browser.getControl(name='type').value = ['plone.app.til... |
if 'buttons.save' or 'buttons.cancel' in self.request.form: | if 'buttons.save' in self.request.form or 'buttons.cancel' in self.request.form: | def update(self): if 'buttons.save' or 'buttons.cancel' in self.request.form: self.ignoreRequest = False |
fixtures = ['pylucid.json'] | # def test_basic_addition(self): | |
self.assertResponse(response, must_contain=( '1-rootpage content', '<title>1-rootpage title', '<span class="PyLucidPlugins auth" id="auth_lucidTag">', '<a href="?auth=login"', 'id="login_link', ), must_not_contain=('Error', "traceback", 'Permission denied'), ) | self.assertAdminLoginPage(response) | def test_login_link(self): """ Simple check if login link exist. """ response = self.client.get("/admin/", HTTP_ACCEPT_LANGUAGE="en") self.assertResponse(response, must_contain=( # PageContent: '1-rootpage content', '<title>1-rootpage title', # Login in link: '<span class="PyLucidPlugins auth" id="auth_lucidTag">', '<a... |
error_msg = err | error_msg = unicode(err) | def _wrong_login(request, debug_msg, user=None): """ username or password is wrong. """ if settings.DEBUG: error_msg = debug_msg else: error_msg = _("Wrong username/password.") # Protection against DOS attacks. pref_form = AuthPreferencesForm() preferences = pref_form.get_preferences() min_pause = preferences["min_pau... |
user2 = auth.authenticate( user=user1, challenge=challenge, sha_a2=sha_a2, sha_b=sha_b, sha_checksum=sha_checksum ) | try: user2 = auth.authenticate( user=user1, challenge=challenge, sha_a2=sha_a2, sha_b=sha_b, sha_checksum=sha_checksum ) except Exception, err: debug_msg = "auth.authenticate() failed: %s" % err return _wrong_login(request, debug_msg, user1) | def _sha_auth(request): """ login the user with username and sha values. """ response = _is_post_ajax_request(request) if response is not None: # It's not a Ajax POST request return response # Return HttpResponseBadRequest form = ShaLoginForm(request.POST) if not form.is_valid(): debug_msg = "ShaLoginForm is not valid... |
management.call_command('test', __file__, verbosity=1) | management.call_command('test', __file__, verbosity=2) | def test_login_ajax_form(self): """ Check if we get the login form via AJAX """ response = self.client.get(LOGIN_URL, HTTP_X_REQUESTED_WITH='XMLHttpRequest') self.failUnlessEqual(response.status_code, 200) self.assertResponse(response, must_contain=( '<div class="PyLucidPlugins auth" id="auth_http_get_view">', "JS-SHA-... |
def binary2base64(binary_file, output_file): | def binary2base64(binary_file): | def binary2base64(binary_file, output_file): """ Convert a binary file (OGG, executable, etc.) to a printable string. """ # Use mode = "rb" to read binary file fin = open(binary_file, "rb") binary_data = fin.read() fin.close() # Encode binary to base64 string (printable) return base64.b64encode(binary_data) """fout ... |
_log(2, "_connection_notinuse", ref) if _refs is None or _make_available is None or _Connection is None: | if _refs is None: | def _connection_notinuse(ref): # if the Python interpreter is exiting, the globals might already have # been deleted, so check for them explicitly _log(2, "_connection_notinuse", ref) if _refs is None or _make_available is None or _Connection is None: return inner = _refs[ref] del _refs[ref] _log(3, "_connection_notinu... |
_log(3, "_connection_notinuse: inner=%r" % inner) | def _connection_notinuse(ref): # if the Python interpreter is exiting, the globals might already have # been deleted, so check for them explicitly _log(2, "_connection_notinuse", ref) if _refs is None or _make_available is None or _Connection is None: return inner = _refs[ref] del _refs[ref] _log(3, "_connection_notinu... | |
_make_available(_Connection(inner)) | if _make_available is not None and _Connection is not None: _make_available(_Connection(inner)) | def _connection_notinuse(ref): # if the Python interpreter is exiting, the globals might already have # been deleted, so check for them explicitly _log(2, "_connection_notinuse", ref) if _refs is None or _make_available is None or _Connection is None: return inner = _refs[ref] del _refs[ref] _log(3, "_connection_notinu... |
_make_available(_Connection(None, conn, *self._args, **self._kwargs)) | if _make_available is not None: _make_available(_Connection(None, conn, *self._args, **self._kwargs)) | def close(self): _log(3, "_Connection.close", self) if self._cursorref is not None: c = self._cursorref() if c is not None: _log(4, "_Connection.close: closing cursor %r" % c) c.close() self._cursorref = None self._outerref = None conn = self._connection if conn: self._connection = None _make_available(_Connection(None... |
notification_center.remove_observer(self, sender=stream) stream.deactivate() stream.end() | try: notification_center.remove_observer(self, sender=stream) except KeyError: pass else: stream.deactivate() stream.end() | def _fail_proposal(self, originator, error): notification_center = NotificationCenter() for stream in self.proposed_streams: notification_center.remove_observer(self, sender=stream) stream.deactivate() stream.end() if originator == 'remote' and self._invitation.sub_state == 'received_proposal': self._invitation.send_re... |
if port.consumer_slot is not None: | if port.consumer_slot is not None and self.demultiplexer.slot: | def add(self, port): with self._lock: if not IAudioPort.providedBy(port): raise TypeError("expected object implementing IAudioPort, got %s" % port.__class__.__name__) if port.mixer is not self.mixer: raise ValueError("expected port with Mixer %r, got %r" % (self.mixer, port.mixer)) if weakref.ref(port) in self.ports: r... |
if port.producer_slot is not None: | if port.producer_slot is not None and self.multiplexer.slot: | def add(self, port): with self._lock: if not IAudioPort.providedBy(port): raise TypeError("expected object implementing IAudioPort, got %s" % port.__class__.__name__) if port.mixer is not self.mixer: raise ValueError("expected port with Mixer %r, got %r" % (self.mixer, port.mixer)) if weakref.ref(port) in self.ports: r... |
if port.consumer_slot is not None: | if port.consumer_slot is not None and self.demultiplexer.slot: | def remove(self, port): with self._lock: if weakref.ref(port) not in self.ports: raise ValueError("port %r is not part of this bridge" % port) if port.consumer_slot is not None: self.mixer.disconnect_slots(self.demultiplexer.slot, port.consumer_slot) if port.producer_slot is not None: self.mixer.disconnect_slots(port.p... |
if port.producer_slot is not None: | if port.producer_slot is not None and self.multiplexer.slot: | def remove(self, port): with self._lock: if weakref.ref(port) not in self.ports: raise ValueError("port %r is not part of this bridge" % port) if port.consumer_slot is not None: self.mixer.disconnect_slots(self.demultiplexer.slot, port.consumer_slot) if port.producer_slot is not None: self.mixer.disconnect_slots(port.p... |
except SIPRegistrationDidNotEnd, e: | except (SIPRegistrationDidFail, SIPRegistrationDidNotEnd), e: | def _CH_unregister(self, command): notification_center = NotificationCenter() # Cancel any timer which would restart the registration process if self._refresh_timer is not None and self._refresh_timer.active(): self._refresh_timer.cancel() self._refresh_timer = None self.registered = False if self._registration is not ... |
while True: notification = self._data_channel.wait() if notification.sender is subscription and notification.name == 'SIPSubscriptionDidEnd': break | try: while True: notification = self._data_channel.wait() if notification.sender is subscription and notification.name == 'SIPSubscriptionDidEnd': break except SIPSubscriptionDidFail: pass | def _CH_unsubscribe(self, command): # Cancel any timer which would restart the subscription process if self._subscription_timer is not None and self._subscription_timer.active(): self._subscription_timer.cancel() self._subscription_timer = None self.subscribed = False if self.subscription is not None: subscription = se... |
data = self._data_channel.wait() | while True: notification = self._data_channel.wait() if notification.name == 'SIPRegistrationDidSucceed': break | def _CH_register(self, command): notification_center = NotificationCenter() settings = SIPSimpleSettings() try: # Cancel any timer which would refresh the registration if self._refresh_timer is not None and self._refresh_timer.active(): self._refresh_timer.cancel() self._refresh_timer = None |
data=TimestampedNotificationData(contact_header=data.contact_header, contact_header_list=data.contact_header_list, expires=data.expires_in, | data=TimestampedNotificationData(contact_header=notification.data.contact_header, contact_header_list=notification.data.contact_header_list, expires=notification.data.expires_in, | def _CH_register(self, command): notification_center = NotificationCenter() settings = SIPSimpleSettings() try: # Cancel any timer which would refresh the registration if self._refresh_timer is not None and self._refresh_timer.active(): self._refresh_timer.cancel() self._refresh_timer = None |
self._data_channel.wait() | while True: notification = self._data_channel.wait() if notification.name == 'SIPRegistrationDidEnd': break | def _CH_unregister(self, command): notification_center = NotificationCenter() # Cancel any timer which would restart the registration process if self._refresh_timer is not None and self._refresh_timer.active(): self._refresh_timer.cancel() self._refresh_timer = None if self._registration is not None: self._registration... |
self._data_channel.send(notification.data) | self._data_channel.send(notification) | def _NH_SIPRegistrationDidSucceed(self, notification): self._data_channel.send(notification.data) |
self._data_channel.send(notification.data) | self._data_channel.send(notification) | def _NH_SIPRegistrationDidEnd(self, notification): self._data_channel.send(notification.data) |
command.wait() | def restart_registration(self): command = Command('unregister') self._command_channel.send(command) command.wait() command = Command('register') reactor.callLater(1, self._command_channel.send, command) | |
reactor.callLater(1, self._command_channel.send, command) | self._command_channel.send(command) | def restart_registration(self): command = Command('unregister') self._command_channel.send(command) command.wait() command = Command('register') reactor.callLater(1, self._command_channel.send, command) |
ready = select.select(self._files, [], []) | ready = select.select([f for f in self._files if not f.active], [], [])[0] | def _process_files(self): while True: try: ready = select.select(self._files, [], []) except RestartSelect: continue else: self._files = [f for f in self._files if f not in ready[0] and not f.closed] self._command_channel.send(Command('process_results', files=[f for f in ready[0] if not f.closed])) |
self._files = [f for f in self._files if f not in ready[0] and not f.closed] self._command_channel.send(Command('process_results', files=[f for f in ready[0] if not f.closed])) | for file in ready: file.active = True self._command_channel.send(Command('process_results', files=[f for f in ready if not f.closed])) | def _process_files(self): while True: try: ready = select.select(self._files, [], []) except RestartSelect: continue else: self._files = [f for f in self._files if f not in ready[0] and not f.closed] self._command_channel.send(Command('process_results', files=[f for f in ready[0] if not f.closed])) |
for file in (f for f in command.files if not f.closed): self._files.append(file) | for file in command.files: file.active = False self._files = [f for f in self._files if not f.closed] | def _CH_process_results(self, command): for file in (f for f in command.files if not f.closed): try: bonjour.DNSServiceProcessResult(file.file) except: # Should we close the file? The documentation doesn't say anything about this. -Luci import traceback traceback.print_exc() # reinsert the files which were not closed i... |
if isinstance(document, str): | if isinstance(document, basestring): | def parse(cls, document, *args, **kwargs): try: if isinstance(document, str): xml = etree.XML(document, parser=cls._xml_parser) else: xml = etree.parse(document, parser=cls._xml_parser).getroot() except etree.XMLSyntaxError, e: raise ParserError(str(e)) else: kwargs.setdefault('xml_application', cls._xml_application) r... |
return self._registrar.registered | return self._registrar.registered if self._registrar else False | def registered(self): return self._registrar.registered |
if 'message_summary.enabled' in notification.data.modified): | if 'message_summary.enabled' in notification.data.modified: | def _NH_CFGSettingsObjectDidChange(self, notification): # activate/deactivate the account or start/stop/reload the registration process if self._started: if 'enabled' in notification.data.modified: if self.enabled: self._activate() else: self._deactivate() elif self.enabled: registrar_attributes = ['auth.password', 'au... |
notification_center = NotificationCenter() | if self.state == 'terminated': return | def _NH_SIPInvitationChangedState(self, notification): notification_center = NotificationCenter() if self.greenlet is not None: if notification.data.state == 'disconnected' and notification.data.prev_state != 'disconnecting': self._channel.send_exception(InvitationDidFailError(notification.sender, notification.data)) e... |
self.cpim_enabled = contains_mime_type(self.accept_types, 'message/cpim') | self.cpim_enabled = contains_mime_type(self.accept_types, 'message/cpim') and contains_mime_type(remote_accept_types.split(), 'message/cpim') | def start(self, local_sdp, remote_sdp, stream_index): self.greenlet = api.getcurrent() notification_center = NotificationCenter() try: context = 'sdp_negotiation' self.remote_identity = ChatIdentity(self.session.remote_identity.uri, self.session.remote_identity.display_name) remote_media = remote_sdp.media[stream_index... |
if uri != self.account.contact[uri.parameters.get('transport', 'udp')]: | if uri != self.account.contact[uri.parameters.get('transport', 'udp')] and uri in self._neighbours: self._neighbours.remove(uri) | def _browse_cb(self, file, flags, interface_index, error_code, service_name, regtype, reply_domain): notification_center = NotificationCenter() if error_code != bonjour.kDNSServiceErr_NoError: self._discover_timer = reactor.callLater(1, self._command_channel.send, Command('discover')) return if not (flags & bonjour.kDN... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.