rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
forums = portal.searchCatalog({'meta_type': 'Naaya Forum'}, None, None) for forum in forums: | catalog = portal.getCatalogTool() for brain in catalog(meta_type='Naaya Forum'): forum = brain.getObject() | def _update(self, portal): topics_stats = {} forums = portal.searchCatalog({'meta_type': 'Naaya Forum'}, None, None) for forum in forums: self.log.debug('Found forum at %r' % forum.absolute_url(1)) stats_container = forum._getStatisticsContainer() if isinstance(stats_container, NyGadflyContainer): self.log.debug('Migra... |
except AttributeError: | except: | def get_list_nodes(self, list_id): """ Return a list with the items of the selection list, first try RefLists then try RefTrees""" ptool = self.getPortletsTool() try: return ptool.getRefListById(list_id).get_list() except AttributeError: try: tree_thread = ptool.getRefTreeById(list_id).get_tree_thread() return [x['ob']... |
except AttributeError: | except: | def get_node_title(self, list_id, node_id): ptool = self.getPortletsTool() try: return ptool.getRefListById(list_id).get_item(node_id).title except AttributeError: try: return ptool.getRefTreeById(list_id)[node_id].title except AttributeError: '' |
except AttributeError: '' | except: return '' | def get_node_title(self, list_id, node_id): ptool = self.getPortletsTool() try: return ptool.getRefListById(list_id).get_item(node_id).title except AttributeError: try: return ptool.getRefTreeById(list_id)[node_id].title except AttributeError: '' |
self.setSessionInfo([MESSAGE_SAVEDCHANGES % self.utGetTodayDate()]) | self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES, date=self.utGetTodayDate()) | def saveProperties(self, title='', description='', sortorder='', start_date='', end_date='', public_registration='', allow_file='', file='', lang='', REQUEST=None): """ """ |
return ICaptcha(self).is_available | return ICaptcha(self.getSite()).is_available | def recaptcha_is_present(self): return ICaptcha(self).is_available |
return ICaptcha(self).render_captcha() | return ICaptcha(self.getSite()).render_captcha() | def show_recaptcha(self, context): """ Returns HTML code for reCAPTCHA """ return ICaptcha(self).render_captcha() |
return ICaptcha(self).is_valid_captcha(REQUEST) | return ICaptcha(self.getSite()).is_valid_captcha(REQUEST) | def is_valid_recaptcha(self, context, REQUEST): """ Test if reCaptcha is valid. """ return ICaptcha(self).is_valid_captcha(REQUEST) |
addNyDocument(archive, id=id, title='', body='') | addNyDocument(archive, id=id, title=title) | def save_flash(self, results, p_type): """ """ template = self._getOb(self.df_template) archive = self.getFlashArchive() #create mail document id = '%s_%s' % (self.lastflashdate, p_type) doc_obj = archive._getOb(id, None) if doc_obj is None: addNyDocument(archive, id=id, title='', body='') doc_obj = archive._getOb(id, ... |
doc_obj.saveProperties(title='Flash to be sent on %s (%s version)' % (self.utShowDateTime(self.notif_date), p_type), body=x, lang=k) | doc_obj.saveProperties(title=title, body=x, lang=k) | def save_flash(self, results, p_type): """ """ template = self._getOb(self.df_template) archive = self.getFlashArchive() #create mail document id = '%s_%s' % (self.lastflashdate, p_type) doc_obj = archive._getOb(id, None) if doc_obj is None: addNyDocument(archive, id=id, title='', body='') doc_obj = archive._getOb(id, ... |
if PERMISSION_GROUP not in auth_tool.listPermissions().keys(): | if PERMISSION_GROUP not in self.get_naaya_permissions_in_site(): | def checkReviewerRole(self): """ Checks if the 'Reviewer' role exists, creates and adds review permissions if it doesn't exist """ |
security.declarePrivate('get_invitation') | security.declareProtected(PERMISSION_INVITE_TO_TALKBACKCONSULTATION, 'get_invitation') | def get_current_invitation(self, REQUEST): return self.get_invitation(REQUEST.SESSION.get('nytb-current-key', None)) |
return SimpleUser('invited_reviewer', '', ('InvitedReviewer',), []) | return SimpleUser('invite:' + invitation.key, '', ('InvitedReviewer',), []) | def authenticate(self, name, password, request): invitation = self.invitations.get_current_invitation(request) if invitation is not None and invitation.enabled: return SimpleUser('invited_reviewer', '', ('InvitedReviewer',), []) else: return None |
for key, value in self.application_data: | for key, value in self.application_data.items(): | def get_application_data(self): for key, value in self.application_data: self.application_data[key] = make_unicode(value) return self.application_data |
cn = user.get('cn', '') organization = user.get('o', '') | cn = _encode(user.get('cn', '')) organization = _encode(user.get('o', '')) | def userMatched(uid, cn): if search_param == 'uid': return search_term in uid if search_param == 'cn': return search_term in cn return False |
results.extend(self.query_objects_ex(meta_type, query, self.gl_get_selected_language(), path=REQUEST.get('path', ''), approved=1)) | results.extend(self.query_objects_ex(meta_type, query, self.gl_get_selected_language(), path=path, approved=1)) | def search(self, REQUEST): """ folder search """ results = [] query = REQUEST.get('query', '') meta_type = self.get_meta_types() if query: results = [] results.extend(self.query_objects_ex(meta_type, query, self.gl_get_selected_language(), path=REQUEST.get('path', ''), approved=1)) results = self.utEliminateDuplicatesB... |
return self._search(REQUEST, results=results) | folder = self.restrictedTraverse(path) return _search.__of__(folder)(REQUEST, results=results) | def search(self, REQUEST): """ folder search """ results = [] query = REQUEST.get('query', '') meta_type = self.get_meta_types() if query: results = [] results.extend(self.query_objects_ex(meta_type, query, self.gl_get_selected_language(), path=REQUEST.get('path', ''), approved=1)) results = self.utEliminateDuplicatesB... |
return self.data | if isinstance(self.data, unicode): return self.data.deocde('utf-8') else: return self.data | def getZipData(self): return self.data |
def __get_tree_rec(self, node): """ Traverse the tree """ if node.id not in self.visited: if node.parent == None or node.parent in self.visited: self.visited.append(node.id) ret_dict = {} ret_dict[node] = [] if hasattr(node, 'children'): ret_dict[node] = map(self.__get_tree_rec, node.children) return ret_dict | def get_node_children(self, parent = None): """ return child nodes for parent ordered by weight """ return self.utSortObjsListByAttr([x for x in self.get_tree_nodes() if parent == x.parent ], 'weight', 0) | |
self.visited = [] | visited = [] def recurse_get_tree(node): if node.id not in visited: if node.parent == None or node.parent in visited: visited.append(node.id) ret_dict = {} ret_dict[node] = [] if hasattr(node, 'children'): ret_dict[node] = map(recurse_get_tree, node.children) return ret_dict | def get_tree(self): """ Get tree as a list of dictionaries ordered by weight """ nodes = self.get_tree_nodes() data = [] for node in nodes: node.children = self.get_node_children(node.id) self.visited = [] for node in nodes: res = self.__get_tree_rec(node) if res: data.append(res) del(self.visited) return data |
res = self.__get_tree_rec(node) | res = recurse_get_tree(node) | def get_tree(self): """ Get tree as a list of dictionaries ordered by weight """ nodes = self.get_tree_nodes() data = [] for node in nodes: node.children = self.get_node_children(node.id) self.visited = [] for node in nodes: res = self.__get_tree_rec(node) if res: data.append(res) del(self.visited) return data |
del(self.visited) | def get_tree(self): """ Get tree as a list of dictionaries ordered by weight """ nodes = self.get_tree_nodes() data = [] for node in nodes: node.children = self.get_node_children(node.id) self.visited = [] for node in nodes: res = self.__get_tree_rec(node) if res: data.append(res) del(self.visited) return data | |
if len(r): | if len(res): | def internalSearch(self, query='', langs=None, releasedate=None, releasedate_range=None, meta_types=[], skey='', rkey='', start='', path=''): """ """ r = [] rex = r.extend if langs is None: langs = [self.gl_get_selected_language()] try: start = int(start) except: start = 0 releasedate = self.utConvertStringToDateTimeOb... |
if search_method == 'getNewsListing': list_results = results else: page_info, list_results = results objects = list_results[2] objects = [x[2] for x in objects] | objects = [x.getObject() for x in results[ int(form.get('ps_start', 0)):int(form.get('items', 10))]] | def search_rdf(self, REQUEST=None, **kwargs): """ """ search_mapping = RDF_SEARCH_MAPPING search_query_mapping = RDF_SEARCH_QUERY_MAPPING |
pag_info, list_results = results objects = list_results[2] objects = [x[2] for x in objects] | objects = [x.getObject() for x in results[ int(form.get('ps_start', 0)):int(form.get('items', 10))]] | def search_atom(self, REQUEST=None, RESPONSE=None, **kwargs): """ """ search_mapping = RDF_SEARCH_MAPPING search_query_mapping = RDF_SEARCH_QUERY_MAPPING |
delete_species = list(schema_raw_data.pop('delete_species', '')) | delete_species = sorted(list(schema_raw_data.pop('delete_species', '')), reverse=True) | def saveProperties(self, REQUEST=None, **kwargs): """ """ if not self.checkPermissionEditObject(): raise EXCEPTION_NOTAUTHORIZED, EXCEPTION_NOTAUTHORIZED_MSG |
self.selenium.click("//input[@value='Delete selected user(s)']") | self.selenium.click("css=.deluser") assert re.search(r"^Are you sure[\s\S]$", self.selenium.get_confirmation()) | def test_delete_user(self): self.selenium.open("/portal/admin_local_users_html", True) #Check the last user checkbox self.selenium.click( "//div[@class='datatable']/table/tbody/tr[last()]/td/input") username = self.selenium.get_text( "//div[@class='datatable']/table/tbody/tr[last()]/td[2]") self.selenium.click("//input... |
self.selenium.open("/portal/admin_local_users_html", True) self.selenium.type('id=autocomplete-query', ' ') self.selenium.type_keys('id=autocomplete-query', 'contri') self.selenium.wait_for_condition('window.selenium_ready == true', 3000) | self.selenium.open("/portal/admin_local_users_html", True) self.selenium.type('id=autocomplete-query', 'contributor') self.selenium.click('//input[@value="Search"]') self.selenium.wait_for_condition('window.selenium_ready == true', 3000) | def check_result(user): "Check if the user is alone in the result list" #Also check if the the results are right assert self.selenium.get_text(\ '//div[@class="datatable"]/table/tbody/tr[last()]/td[2]') ==\ user |
self.selenium.type_keys('id=autocomplete-query', ' ') | self.selenium.click('//input[@value="Search"]') | def check_result(user): "Check if the user is alone in the result list" #Also check if the the results are right assert self.selenium.get_text(\ '//div[@class="datatable"]/table/tbody/tr[last()]/td[2]') ==\ user |
self.selenium.type('id=autocomplete-query', 'contrib') self.selenium.click('//input[@value="Go"]') self.selenium.wait_for_page_to_load("3000") check_result(u'contributor') | self.selenium.select("id=filter-roles", 'Manager') self.selenium.click('//input[@value="Search"]') self.selenium.wait_for_condition('window.selenium_ready == true', 3000) check_result(u'test_user_1_') | def check_result(user): "Check if the user is alone in the result list" #Also check if the the results are right assert self.selenium.get_text(\ '//div[@class="datatable"]/table/tbody/tr[last()]/td[2]') ==\ user |
self.selenium.click('//input[@value="Go"]') | self.selenium.click('//input[@value="Search"]') | def check_result(user): "Check if the user is alone in the result list" #Also check if the the results are right assert self.selenium.get_text(\ '//div[@class="datatable"]/table/tbody/tr[last()]/td[2]') ==\ user |
def test_aaaassign_role(self): | def test_assign_role(self): | def test_aaaassign_role(self): """Assign a role XXX: Do the jstree click """ self.selenium.open("/portal/admin_assignroles_html", True) self.selenium.add_selection("names", "label=user3") self.selenium.add_selection("//select[@name='roles']", 'Manager') self.selenium.type('location', "info") self.selenium.click("//inpu... |
embed_map_html = PageTemplateFile('zpt/map_embed', globals()) | _embed_map_html = PageTemplateFile('zpt/map_embed', globals()) def embed_map_html(self, REQUEST): """ embeddable map, for iframe """ if 'map_embed' in self.objectIds(): return self.map_embed(REQUEST) else: return self._embed_map_html(REQUEST) | def _index_template(self): if hasattr(self, 'map_index'): return self._getOb('map_index') for skel_handler in reversed(self.get_all_skel_handlers()): skel_path = skel_handler.skel_path map_index_path = os.path.join(skel_path, 'others', 'map_index.zpt') if os.path.isfile(map_index_path): return PageTemplateFile(map_inde... |
for key, value in kwargs.items(): | field_ids = [ob.prop_name() for ob in context._get_schema().objectValues() if ob.visible] for key in field_ids: | def updateSessionFrom(self, REQUEST=None, **kwargs): """Update session from a given language""" # Update kwargs from request if not REQUEST: return parents = REQUEST.get('PARENTS', None) if not parents: return |
attrs = acl_folder.getSchemaConfig().keys() attrs.extend(['o', 'postalAddress']) users = acl_folder.findUser(search_param='uid', search_term=uid, attrs=attrs) for user in users: if user.get('uid', '') == uid: return user def _get_user_email(self, user): if user is not None: return unicode(user.get('mail', ''), 'iso-88... | user = acl_folder.getUser(uid) return user def _get_user_email(self, user, default=''): if user is None or not hasattr(user, 'mail'): return default return user.mail | def _get_user_by_uid(self, uid, acl_folder): attrs = acl_folder.getSchemaConfig().keys() attrs.extend(['o', 'postalAddress']) users = acl_folder.findUser(search_param='uid', search_term=uid, attrs=attrs) for user in users: if user.get('uid', '') == uid: return user |
def _get_user_full_name(self, user): if user is not None: return unicode(user.get('cn', ''), 'iso-8859-1').encode('utf-8') else: return '' | def _get_user_first_name(self, user, default=''): if user is None or not hasattr(user, 'givenName'): return default return user.givenName def _get_user_last_name(self, user, default=''): if user is None or not hasattr(user, 'lastname'): return default return user.lastname def _get_user_full_name(self, user, default='... | def _get_user_full_name(self, user): if user is not None: return unicode(user.get('cn', ''), 'iso-8859-1').encode('utf-8') else: return '' |
def _get_user_organisation(self, user): if user is not None: return unicode(user.get('o', ''), 'iso-8859-1').encode('utf-8') else: return '' def _get_user_postal_address(self, user): if user is not None: return unicode(user.get('postalAddress', ''), 'iso-8859-1').encode('utf-8') else: return '' | def _get_user_organisation(self, user, default=''): if user is None or not hasattr(user, 'o'): return default return user.o def _get_user_postal_address(self, user, default=''): if user is None or not hasattr(user, 'postalAddress'): return default return user.postalAddress | def _get_user_organisation(self, user): if user is not None: return unicode(user.get('o', ''), 'iso-8859-1').encode('utf-8') else: return '' |
'email': user['mail'], | 'email': user.get('mail', ''), | def handle_unicode(s): if not isinstance(s, unicode): try: return s.decode('utf-8') except: return s.decode('latin-1') else: return s |
self.contributor = contributor | def __init__(self, id, title, description, sortorder, start_date, end_date, public_registration, allow_file, contributor, releasedate, lang): """ """ self.id = id self.contributor = contributor NyValidation.__dict__['__init__'](self) NyCheckControl.__dict__['__init__'](self) NyContainer.__dict__['__init__'](self) BTree... | |
self.setSessionInfo([MESSAGE_SAVEDCHANGES % self.utGetTodayDate()]) | self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES, date=self.utGetTodayDate()) | def saveProperties(self, REQUEST=None, **kwargs): """ """ |
security.declareProtected(view, 'checkPermissionParticipateInMeeting') | def saveProperties(self, REQUEST=None, **kwargs): """ """ if not self.checkPermissionEditObject(): raise EXCEPTION_NOTAUTHORIZED, EXCEPTION_NOTAUTHORIZED_MSG | |
security.declareProtected(view, 'checkPermissionAdminMeeting') | def checkPermissionParticipateInMeeting(self): """ """ return self.checkPermission(PERMISSION_PARTICIPATE_IN_MEETING) | |
security.declareProtected(view, 'checkPermissionChangePermissions') | def checkPermissionAdminMeeting(self): """ """ return self.checkPermission(PERMISSION_ADMIN_MEETING) | |
day_len='2', cal_meta_types='Naaya Event', start_day='Monday', catalog=self.getCatalogTool().id, REQUEST=None) | day_len='2', start_day='Monday', catalog=self.getCatalogTool().id, REQUEST=None) calendar = self._getOb('portal_calendar') calendar.cal_meta_types = calendar.setCalMetaTypes('Naaya Event') | def loadDefaultData(self): """ """ #set default 'Naaya' configuration NySite.__dict__['createPortalTools'](self) NySite.__dict__['loadDefaultData'](self) |
title=item.absolute_url(1) | title=path_in_site(item) | def recurse(items, level=0, stop_level=2): """ Create a dict with node properties and children """ res = [] for item in items: children_items = [] if level != stop_level: node = path_in_site(item) if all: items = self.getFolderContent(node) else: items = self.getFolderPublishedContent(node) children_items = recurse( it... |
if REQUEST: | if REQUEST is not None: | def admin_addworkgroup(self, title='', location='', role='', REQUEST=None): """ """ err = [] if title=='': err.append('Title is required') if location=='': err.append('Location is required') else: try: #check for a valid location ob = self.unrestrictedTraverse(location) except: err.append('Invalid location') else: #che... |
self._p_changed = 1 if REQUEST: self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES, date=self.utGetTodayDate()) return REQUEST.RESPONSE.redirect('%s/admin_workgroups_html?w=%s' % (self.absolute_url(), id)) | self._p_changed = True if REQUEST is not None: self.setSessionInfoTrans("Workgroup added") REQUEST.RESPONSE.redirect('%s/admin_workgroups_html?w=%s' % (self.absolute_url(), id)) | def admin_addworkgroup(self, title='', location='', role='', REQUEST=None): """ """ err = [] if title=='': err.append('Title is required') if location=='': err.append('Location is required') else: try: #check for a valid location ob = self.unrestrictedTraverse(location) except: err.append('Invalid location') else: #che... |
if REQUEST: self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES, date=self.utGetTodayDate()) return REQUEST.RESPONSE.redirect('%s/admin_workgroups_html' % self.absolute_url()) | if REQUEST is not None: self.setSessionInfoTrans("Workgroup(s) deleted") return REQUEST.RESPONSE.redirect(redirect_url) | def admin_delworkgroup(self, ids=[], REQUEST=None): """ Delete workgroup(s). """ for id in self.utConvertToList(ids): wg = self.getWorkgroupById(id) if wg: loc = self.unrestrictedTraverse(wg[2]) #remove local roles for x in loc.get_local_roles(): isowner = 0 if 'Owner' in x[1]: isowner = 1 self.del_userfrom_workgroup(l... |
self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES, date=self.utGetTodayDate()) | self.setSessionInfoTrans("User ${name} assigned to workgroup", name=name) | def admin_addusertoworkgroup(self, id='', name='', REQUEST=None): """ Assign an user to an workgroup. """ wg = self.getWorkgroupById(id) if wg: loc = self.unrestrictedTraverse(wg[2]) self.add_userto_workgroup(loc, name, [wg[3]]) if REQUEST: self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES, date=self.utGetTodayDate()) retu... |
self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES, date=self.utGetTodayDate()) return REQUEST.RESPONSE.redirect('%s/admin_workgroup_html?w=%s' % (self.absolute_url(), id)) | self.setSessionInfoTrans("User(s) deleted from workgroup") return REQUEST.RESPONSE.redirect(redirect_url) | def admin_delusersfromworkgroup(self, id='', names=[], REQUEST=None): """ Unassign one or more users from a workgroup. """ wg = self.getWorkgroupById(id) if wg: loc = self.unrestrictedTraverse(wg[2]) for x in loc.get_local_roles(): if x[0] in self.utConvertToList(names): isowner = 0 if 'Owner' in x[1]: isowner = 1 self... |
self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES, date=self.utGetTodayDate()) return REQUEST.RESPONSE.redirect('%s/admin_userroles_html?name=%s' % (self.absolute_url(), name)) security.declareProtected(PERMISSION_PUBLISH_OBJECTS, 'admin_adduserroles') def admin_adduserroles(self, name='', roles=[], loc='allsite', locatio... | self.setSessionInfoTrans("Role(s) revoked") return REQUEST.RESPONSE.redirect(redirect_url) | def admin_revokeuserroles(self, name='', roles=[], REQUEST=None): """ Revoke roles from an user. """ for t in self.utConvertToList(roles): role, location = t.split('||') if location == '/': location = '' loc = self.unrestrictedTraverse(location) if location != '': res = self.utListDifference( loc.get_local_roles_for_us... |
title='MyMeeting', | title='MyMeeting', max_participants='1', | def afterSetUp(self): self.portal.manage_install_pluggableitem('Naaya Meeting') from naaya.content.meeting.meeting import addNyMeeting location = {'geo_location.address': 'Kogens Nytorv 6, 1050 Copenhagen K, Denmark'} addNyMeeting(self.portal.info, 'mymeeting', contributor='contributor', submitted=1, title='MyMeeting',... |
return doc.manageProperties(lang=lang, approved=1) if doc.meta_type in ('Naaya Extended File',): files = doc.getFileItems() files[new_lang] = doc.getFileItem(lang) files = dict([(key, value) for key, value in files.items() if key != lang]) doc.setFileItems(files) kwargs['lang'] = new_lang deny_args = self._get... | else: doc.manageProperties(lang=lang, approved=1) if doc.meta_type in ('Naaya Extended File',): files = doc.getFileItems() files[new_lang] = doc.getFileItem(lang) files = dict([(key, value) for key, value in files.items() if key != lang]) doc.setFileItems(files) kwargs['lang'] = new_lang deny_args = self._getSw... | def switchToLanguage(self, REQUEST=None, **kwargs): """Update session from a given language""" # Update kwargs from request if not REQUEST: return parents = REQUEST.get('PARENTS', None) if not parents: return doc = parents[0] form = getattr(REQUEST, 'form', {}) kwargs.update(form) kwargs['approved'] = 1 lang = kwargs.g... |
REQUEST.RESPONSE.redirect('%s/edit_html?lang=%s' % (doc.absolute_url(), new_lang)) | if REQUEST is not None: REQUEST.RESPONSE.redirect('%s/edit_html?lang=%s' % (doc.absolute_url(), new_lang)) | def switchToLanguage(self, REQUEST=None, **kwargs): """Update session from a given language""" # Update kwargs from request if not REQUEST: return parents = REQUEST.get('PARENTS', None) if not parents: return doc = parents[0] form = getattr(REQUEST, 'form', {}) kwargs.update(form) kwargs['approved'] = 1 lang = kwargs.g... |
folders.sort(operator.attrgetter('sortorder')) | folders.sort(key=operator.attrgetter('sortorder')) | def getPublishedFolders(self): folders = [] for obj in self.objectValues(self.get_naaya_containers_metatypes()): if not getattr(obj, 'approved', False): continue if not getattr(obj, 'submitted', False): continue folders.append(obj) folders.sort(operator.attrgetter('sortorder')) return folders |
try: keywords[l_prop.id] = REQUEST.get(l_prop.id, '') except: keywords[l_prop.id] = '' return keywords | try: output[l_prop.id] = REQUEST.get(l_prop.id, keywords.get(l_prop.id, '')) except: output[l_prop.id] = '' return output | def processDynamicProperties(self, meta_type, REQUEST=None, keywords={}): """ """ for l_prop in self.getDynamicPropertiesTool().getDynamicProperties(meta_type): try: keywords[l_prop.id] = REQUEST.get(l_prop.id, '') except: keywords[l_prop.id] = '' |
if ID_SCHEMATOOL in self.objectIds(): schema_tool = self._getOb(ID_SCHEMATOOL) if pitem['module'] not in schema_tool.objectIds() and pitem['default_schema']: schema_tool.addSchema(pitem['module'], title=pitem['label'], defaults=pitem['default_schema']) | def manage_install_pluggableitem(self, meta_type=None, REQUEST=None): """ Makes the content with the given meta_type available for usage in the portal. Raises ValueError if content does not exist. If the content specifies an `on_install` function in it's `config` this method will call `[on_install](self)` """ data_path... | |
def test_search_local_users(self): | def test_aaaasearch_local_users(self): | def test_search_local_users(self): """Search users using jquery ui autocomplete and normal search using form |
self.selenium.wait_for_condition(self._selenium_page_timeout) | self.selenium.wait_for_condition('window.selenium_ready == true', self._selenium_page_timeout) | def check_result(user): "Check if the user is alone in the result list" #Also check if the the results are right assert self.selenium.get_text(\ "//table[contains(@class, 'datatable')]/tbody/tr[last()]//td[2]") ==\ user |
for name, role in users_roles.items(): full_name = user_source.getUserCanonicalName(name) dummy = DummyUser(name=name, firstname=full_name.split(' ')[0], lastname=u''.join(full_name.split(' ')[1:]), email=user_source.getUserEmail(name, user_folder), roles=role) dummy_users.append(dummy) | if user_folder.meta_type == 'User Folder': for username in user_folder.getUserNames(): dummy_users.append(DummyUser(name=username, firstname='', lastname='', email='', roles='')) elif user_folder.meta_type == 'LDAPUserFolder': for name, role in users_roles.items(): full_name = user_source.getUserCanonicalName(name) du... | def _filter(user): """ Callback used to filter users """ return ( user.name.lower().find(self.utToUtf8(query).lower()) !=-1 or user.email.lower().find(self.utToUtf8(query).lower()) !=-1 or user.firstname.lower().find(self.utToUtf8(query).lower()) !=-1 or user.lastname.lower().find(self.utToUtf8(query).lower()) !=-1 ) |
_admin_stats = NaayaPageTemplateFile('zpt/stats', globals(), 'site_admin_stats') security.declareProtected(PERMISSION_PUBLISH_OBJECTS, 'admin_stats') def admin_stats(self, REQUEST): | _stats_info = NaayaPageTemplateFile('zpt/stats_info', globals(), 'site_admin_stats_info') security.declareProtected(PERMISSION_PUBLISH_OBJECTS, 'stats_info') admin_stats = NaayaPageTemplateFile('zpt/stats', globals(), 'site_admin_stats') security.declareProtected(PERMISSION_PUBLISH_OBJECTS, 'stats_info') def stats_in... | def index_html(self, REQUEST): """ redirect to admin_account """ REQUEST.RESPONSE.redirect(self.absolute_url() + '/admin_account') |
data_to_cache = self._admin_stats(REQUEST) | data_to_cache = self._stats_info(self.REQUEST) | def admin_stats(self, REQUEST): """ """ view_name = 'stats' cached_data = self.get_cache(view_name=view_name) if cached_data is None: # no data in the cache, so cache it data_to_cache = self._admin_stats(REQUEST) self.set_cache(data_to_cache, view_name=view_name) return data_to_cache # get cached data return cached_dat... |
search_results = [] for date in dates: results = self.getSite().getCatalogedObjectsCheckView(meta_type=\ meta_type, start_date={'query': dates, 'range': 'min:max'}) search_results.extend([result for result in results if result not in search_results]) results = self.getSite().getCatalogedObjectsCheckView(meta_type=\ met... | def cgetattr(ob, name, *argv): """ Call getattr result if callable """ attr = getattr(ob, name, *argv) if callable(attr): return attr() else: return attr | |
def list_pluggable_templates(self, portal): """ get filesystem templates from pluggable content """ return [ tpl for meta_type in portal.get_pluggable_metatypes() for tpl in portal.get_pluggable_item(meta_type).get('forms', None) ] | def list_fs_templates(self, portal): """ return the list of the filesystem templates """ portal_path = self.get_portal_path(portal) skel_handler, error = skel_parser().parse(readFile(join(portal_path, 'skel', 'skel.xml'), 'r')) if skel_handler.root.forms is not None: return [f.id for f in skel_handler.root.forms.forms]... | |
self.setSessionInfo([MESSAGE_SAVEDCHANGES % self.utGetTodayDate()]) | self.setSessionInfoTrans(MESSAGE_SAVEDCHANGES, date=self.utGetTodayDate()) | def saveProperties(self, title='', description='', coverage='', keywords='', sortorder='', body='', topic='', scope='', toc='', releasedate='', discussion='', lang=None, REQUEST=None, **kwargs): """ """ if not self.checkPermissionEditObject(): raise EXCEPTION_NOTAUTHORIZED, EXCEPTION_NOTAUTHORIZED_MSG if not sortorder:... |
if not names_file: | if not names_file or len(files) == 0: | def usage(): print "USAGE: %s --names <names-file> [options] <input_files>" % sys.argv[0] print "OPTIONS:" print " --names <names-file> feature type specification file" print " -N <text_expert> choose a text expert between fgram, ngram and sgram" print " -W <ngram_length> specify window length of tex... |
for feature in feature_dict: fp.write("%s %d\n" % (feature, feature_dict[feature])) | for feature, value in sorted(feature_dict.items(), lambda x, y: cmp(x[1], y[1])): fp.write("%s %d\n" % (feature, value)) | def usage(): print "USAGE: %s --names <names-file> [options] <input_files>" % sys.argv[0] print "OPTIONS:" print " --names <names-file> feature type specification file" print " -N <text_expert> choose a text expert between fgram, ngram and sgram" print " -W <ngram_length> specify window length of tex... |
if len(features) == 0 and not keep_empty_examples: continue | unique_features = {} for feature in features: if feature[0] not in unique_features: unique_features[feature[0]] = float(feature[1]) else: unique_features[feature[0]] += float(feature[1]) if len(unique_features) == 0 and not keep_empty_examples: continue | def usage(): print "USAGE: %s --names <names-file> [options] <input_files>" % sys.argv[0] print "OPTIONS:" print " --names <names-file> feature type specification file" print " -N <text_expert> choose a text expert between fgram, ngram and sgram" print " -W <ngram_length> specify window length of tex... |
output_fp.write(("%d " % label_dict[label]) + " ".join(["%d:%g" % (x[0],x[1]) for x in sorted(features, lambda x ,y: cmp(x[0], y[0]))]) + "\n") | output_fp.write(("%d " % label_dict[label]) + " ".join(["%d:%g" % (x[0],x[1]) for x in sorted(unique_features.items(), lambda x ,y: cmp(x[0], y[0]))]) + "\n") | def usage(): print "USAGE: %s --names <names-file> [options] <input_files>" % sys.argv[0] print "OPTIONS:" print " --names <names-file> feature type specification file" print " -N <text_expert> choose a text expert between fgram, ngram and sgram" print " -W <ngram_length> specify window length of tex... |
if partialurl.startswith("http://"): | if partialurl.startswith("http://") or partialurl.startswith("https://"): | def getmanifest(partialurl, suppress_errors=False): """ Gets a manifest from the server """ manifestbaseurl = munkicommon.pref('ManifestURL') or \ munkicommon.pref('SoftwareRepoURL') + "/manifests/" if not manifestbaseurl.endswith('?') and \ not manifestbaseurl.endswith('/'): manifestbaseurl = manifestbaseurl + "/" mun... |
def AddHashesToPkginfoPlists(pkgsinfo_path, pkgs_path): | def AddHashesToPkginfoPlists(pkgsinfo_path, pkgs_path, update_existing=False): | def AddHashesToPkginfoPlists(pkgsinfo_path, pkgs_path): """Recursively updates plists' '(un)installer_item_hash' kay with pkg hash. Args: pkgsinfo_path: root dir to start updating from. pkgs_path: root dir where Munki pkgs live. """ for f_path in os.listdir(pkgsinfo_path): f_path = os.path.join(pkgsinfo_path, f_path) ... |
pkg_path = os.path.join(pkgs_path, plist['installer_item_location']) if not os.path.isfile(pkg_path): print 'WARNING: Package (%s) not found as specified in %s' % ( pkg_path, f_path) continue pkg_hash = GetSHA256Hash(pkg_path) if 'installer_item_size' in plist: plist['installer_item_hash'] = pkg_hash elif 'uninstall... | updated_hash = False if not 'installer_item_hash' in plist or update_existing: pkg_path = os.path.join(pkgs_path, plist['installer_item_location']) if not os.path.isfile(pkg_path): print >> sys.stderr, ('WARNING: Installer item (%s) not found ' 'as specified in %s') % (pkg_path, f_path) continue plist['installer_it... | def AddHashesToPkginfoPlists(pkgsinfo_path, pkgs_path): """Recursively updates plists' '(un)installer_item_hash' kay with pkg hash. Args: pkgsinfo_path: root dir to start updating from. pkgs_path: root dir where Munki pkgs live. """ for f_path in os.listdir(pkgsinfo_path): f_path = os.path.join(pkgsinfo_path, f_path) ... |
AddHashesToPkginfoPlists(pkgsinfo_path, pkgs_path) | AddHashesToPkginfoPlists(pkgsinfo_path, pkgs_path, options.update_existing) | def main(): usage = 'usage: %prog [options]' p = optparse.OptionParser(usage=usage) p.add_option('-r', '--munki_root', default=MUNKI_ROOT_PATH, help='Munki repo root path where pkginfo and pkgs dirs live; ' 'default "/var/www/munki/repo"') p.add_option('-p', '--pkgsinfo_dir_name', default=MUNKI_PKGSINFO_DIR_NAME, help=... |
processed_installs_names = [nameAndVersion(item)[0] for item in installinfo['processed_installs']] | def getAutoRemovalItems(installinfo, cataloglist): """Gets a list of items marked for automatic removal from the catalogs in cataloglist. Filters those against items in the processed_installs list, which should contain everything that is supposed to be installed. Then filters against the removals list, which contains a... | |
if item not in installinfo['processed_installs'] | if item not in processed_installs_names | def getAutoRemovalItems(installinfo, cataloglist): """Gets a list of items marked for automatic removal from the catalogs in cataloglist. Filters those against items in the processed_installs list, which should contain everything that is supposed to be installed. Then filters against the removals list, which contains a... |
if item['name'] == manifestitem_pl['name']: | if (item.get('name', item['manifestitem']) == manifestitem_pl['name']): | def isItemInInstallInfo(manifestitem_pl, thelist, vers=''): """Determines if an item is in a manifest plist. Returns True if the manifest item has already been processed (it's in the list) and, optionally, the version is the same or greater. """ for item in thelist: try: if item['name'] == manifestitem_pl['name']: if ... |
restartneeded = installer.installWithInfo("/Library/Updates", appleupdatelist) | (restartneeded, unused_skipped_installs) = \ installer.installWithInfo("/Library/Updates", appleupdatelist) | def installAppleUpdates(): '''Uses /usr/sbin/installer to install updates previously downloaded. Some items downloaded by SoftwareUpdate are not installable by /usr/sbin/installer, so this approach may fail to install all downloaded updates''' restartneeded = False appleupdatelist = getSoftwareUpdateInfo() # did we f... |
if name == "NO NAME" or version == "NO VERISON": | if name == "NO NAME" or version == "NO VERSION": | def makeCatalogDB(catalogitems): '''Takes an array of catalog items and builds some indexes so we can get our common data faster. Returns a dict we can use like a database''' name_table = {} pkgid_table = {} itemindex = -1 for item in catalogitems: itemindex = itemindex + 1 name = item.get('name', "NO NAME") vers = it... |
retcode = copyAppFromDMG(itempath, item.get('installer_options',{})) | retcode = copyAppFromDMG(itempath) | def installWithInfo(dirpath, installlist): """ Uses the installlist to install items in the correct order. """ restartflag = False itemindex = 0 for item in installlist: if munkicommon.stopRequested(): return restartflag if "installer_item" in item: itemindex = itemindex + 1 display_name = item.get('display_name') or i... |
(out, unused_err) = proc.communicate() | (out, err) = proc.communicate() if proc.returncode: display_error("installer -query failed: %s" % ( out.decode('UTF-8') + err.decode('UTF-8'))) return None | def getInstallerPkgInfo(filename): """Uses Apple's installer tool to get basic info about an installer item.""" installerinfo = {} proc = subprocess.Popen(['/usr/sbin/installer', '-pkginfo', '-verbose', '-plist', '-pkg', filename], bufsize=1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, unused_err) = proc.comm... |
if (manifestitemname in installinfo['processed_installs'] or manifestitemname_withversion in installinfo['processed_installs']): | if manifestitemname in [nameAndVersion(item)[0] for item in installinfo['processed_installs']]: | def processRemoval(manifestitem, cataloglist, installinfo): """Processes a manifest item; attempts to determine if it needs to be removed, and if it can be removed. Unlike installs, removals aren't really version-specific - If we can figure out how to remove the currently installed version, we do, unless the admin spe... |
if 'CFBundleShortVersionString' in pl: | if pl.get('CFBundleShortVersionString'): | def getVersionString(pl): # Gets a version string from the plist. # if there's a valid CFBundleShortVersionString, returns that. # else if there's a CFBundleVersion, returns that # else returns an empty string. CFBundleShortVersionString = '' if 'CFBundleShortVersionString' in pl: CFBundleShortVersionString = \ pl['CFB... |
if 'CFBundleVersion' in pl: | if pl.get('CFBundleVersion'): | def getVersionString(pl): # Gets a version string from the plist. # if there's a valid CFBundleShortVersionString, returns that. # else if there's a CFBundleVersion, returns that # else returns an empty string. CFBundleShortVersionString = '' if 'CFBundleShortVersionString' in pl: CFBundleShortVersionString = \ pl['CFB... |
13 : "Media opitmization failed", 14 : "Failed due to insuffcient privileges", | 13 : "Media optimization failed", 14 : "Failed due to insufficient privileges", | def adobeSetupError(errorcode): # returns text description for numeric error code # Reference: # http://www.adobe.com/devnet/creativesuite/pdfs/DeployGuide.pdf errormessage = { 0 : "Application installed successfully", 1 : "Unable to parse command line", 2 : "Unknown user interface mode specified", 3 : "Unable to initi... |
'items_to_copy', 'copy_local'] | 'items_to_copy', 'copy_local', 'silent_install'] | def processInstall(manifestitem, cataloglist, installinfo): """Processes a manifest item. Determines if it needs to be installed, and if so, if any items it is dependent on need to be installed first. Items to be installed are added to installinfo['managed_installs'] Calls itself recursively as it processes dependenci... |
return False | updatesindexfile = '/Library/Updates/index.plist' if os.path.exists(appleUpdatesFile) and \ os.path.exists(updatesindexfile): appleUpdatesFile_modtime = os.stat(appleUpdatesFile).st_mtime updatesindexfile_modtime = os.stat(updatesindexfile).st_mtime if appleUpdatesFile_modtime > updatesindexfile_modtime: displayAppleU... | def appleSoftwareUpdatesAvailable(forcecheck=False, suppresscheck=False): '''Checks for available Apple Software Updates, trying not to hit the SUS more than needed''' if suppresscheck: # typically because we're doing a logout install; if # there are no waiting Apple Updates we shouldn't # trigger a check for them ret... |
nameAndVersion in | nameWithVersion in | def lookForUpdates(manifestitem, cataloglist, installinfo): """ Looks for updates for a given manifest item that is either installed or scheduled to be installed. This handles not only specific application updates, but also updates that aren't simply later versions of the manifest item. For example, AdobeCameraRaw is a... |
http_result.startswith('2'): | http_result.startswith('2') and \ temp_download_exists: | def curl(url, destinationpath, onlyifnewer=False, etag=None, resume=False, cacert=None, capath=None, cert=None, key=None, message=None): """Gets an HTTP or HTTPS URL and stores it in destination path. Returns a dictionary of headers, which includes http_result_code and http_result_description. Will raise CurlError if c... |
if not resume and os.path.exists(tempdownloadpath): | if not resume and temp_download_exists: | def curl(url, destinationpath, onlyifnewer=False, etag=None, resume=False, cacert=None, capath=None, cert=None, key=None, message=None): """Gets an HTTP or HTTPS URL and stores it in destination path. Returns a dictionary of headers, which includes http_result_code and http_result_description. Will raise CurlError if c... |
elif http_result.startswith('2'): | elif http_result.startswith('2') and temp_download_exists: | def curl(url, destinationpath, onlyifnewer=False, etag=None, resume=False, cacert=None, capath=None, cert=None, key=None, message=None): """Gets an HTTP or HTTPS URL and stores it in destination path. Returns a dictionary of headers, which includes http_result_code and http_result_description. Will raise CurlError if c... |
if isItemInInstallInfo(item_pl, installinfo['managed_updates']): | if manifestitemname in installinfo['managed_updates']: | def processManagedUpdate(manifestitem, cataloglist, installinfo): """Process a managed_updates item to see if it is installed, and if so, if it needs an update. """ manifestitemname = os.path.split(manifestitem)[1] item_pl = getItemDetail(manifestitem, cataloglist) if not item_pl: munkicommon.display_warning( 'Could n... |
if isItemInInstallInfo(item_pl, installinfo['managed_installs']): munkicommon.display_debug1( '%s has already been processed for install.' % manifestitemname) return if isItemInInstallInfo(item_pl, installinfo['removals']): munkicommon.display_debug1( '%s has already been processed for removal.' % manifestitemname) re... | def processOptionalInstall(manifestitem, cataloglist, installinfo): """Process an optional install item to see if it should be added to the list of optional installs. """ manifestitemname = os.path.split(manifestitem)[1] item_pl = getItemDetail(manifestitem, cataloglist) if not item_pl: munkicommon.display_warning( 'C... | |
munkicommon.display_debug1( "Adding %s to the optional install list" % iteminfo['name']) | def processOptionalInstall(manifestitem, cataloglist, installinfo): """Process an optional install item to see if it should be added to the list of optional installs. """ manifestitemname = os.path.split(manifestitem)[1] item_pl = getItemDetail(manifestitem, cataloglist) if not item_pl: munkicommon.display_warning( 'C... | |
munkicommon.display_debug1( '* Processing manifest item %s for install' % manifestitemname) | def processInstall(manifestitem, cataloglist, installinfo): """Processes a manifest item. Determines if it needs to be installed, and if so, if any items it is dependent on need to be installed first. Items to be installed are added to installinfo['managed_installs'] Calls itself recursively as it processes dependenci... | |
munkicommon.display_detail('Processing manifest item %s...' % manifestitemname_withversion) | munkicommon.display_debug1( '* Processing manifest item %s for removal' % manifestitemname_withversion) | def processRemoval(manifestitem, cataloglist, installinfo): """Processes a manifest item; attempts to determine if it needs to be removed, and if it can be removed. Unlike installs, removals aren't really version-specific - If we can figure out how to remove the currently installed version, we do, unless the admin spe... |
if 'aliases' in item: for alias in item['aliases']: if not alias in name_table: name_table[alias] = {} if not vers in name_table[alias]: name_table[alias][vers] = [] name_table[alias][vers].append(itemindex) | def makeCatalogDB(catalogitems): '''Takes an array of catalog items and builds some indexes so we can get our common data faster. Returns a dict we can use like a database''' name_table = {} pkgid_table = {} itemindex = -1 for item in catalogitems: itemindex = itemindex + 1 name = item.get('name', "NO NAME") vers = it... | |
names.extend(manifestitem_pl.get('aliases',[])) | def isItemInInstallInfo(manifestitem_pl, thelist, vers=''): """ Returns True if the manifest item has already been processed (it's in the list) and, optionally, the version is the same or greater. """ names = [] names.append(manifestitem_pl.get('name')) names.extend(manifestitem_pl.get('aliases',[])) for item in thelis... | |
if not catalogname in catalog.keys(): continue | def compare_version_keys(a, b): return cmp(version.LooseVersion(b), version.LooseVersion(a)) | |
if 'aliases' in pl: for alias in pl['aliases']: if alias in pkgdata['installed_names']: return True | def evidenceThisIsInstalled(pl): """ Checks to see if there is evidence that the item described by pl (any version) is currently installed. If any tests pass, the item might be installed. So this isn't the same as isInstalled() """ global pkgdata if pl.get('uninstall_method') == "removepackages": # we're supposed to u... | |
autoremovalnames += catalog[catalogname]['autoremoveitems'] | if catalogname in catalog.keys(): autoremovalnames += catalog[catalogname]['autoremoveitems'] | def getAutoRemovalItems(installinfo, cataloglist): '''Gets a list of items marked for automatic removal from the catalogs in cataloglist. Filters those against items in the managed_installs list, which should contain everything that is supposed to be installed. ''' autoremovalnames = [] for catalogname in cataloglist: ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.