Пример #1
0
def triggerPloneImportFromRecensio():
    trigger_url, trigger_user, trigger_pass = sys.argv[1:4]
    target_url, user, password = map(urllib.quote, sys.argv[4:7])
    browser = Browser('%s?url=%s&user=%s&password=%s' % (trigger_url, target_url,\
        user, password))
    browser.getControl(name = '__ac_name').value = trigger_user
    browser.getControl(name = '__ac_password').value = trigger_pass
    browser.getControl('Anmelden').click()
Пример #2
0
 def __call__(self, url, user, password):
     count = 0
     browser = Browser(url)
     browser.getControl(name = '__ac_name').value = user
     browser.getControl(name = '__ac_password').value = password
     browser.getControl('Log in').click()
     objects = xmlrpclib.loads(browser.contents)[0][0]
     import_utility = IRecensioImport(self.context)
     for object in objects:
         path = object['path']
         if import_utility.exists(path):
             raise Exception('Object already exists')
         else:
             self.add(object)
             count += 1
             import_utility.add(path)
     return "Successfully imported %i items" % count
Пример #3
0
def createSite():
    profile = ['recensio.policy:default']
    try:
        host = sys.argv[1]
        user = sys.argv[2]
        passwd = sys.argv[3]
        profile = [sys.argv[4]]
    except:
        pass
    base64string = base64.encodestring('%s:%s' % (user, passwd))[:-1]
    br = Browser(sys.argv[1])
    print "Trying to create new plone site"
    br.addHeader('Authorization', 'Basic %s' % base64string)
    br.getControl('Create a new Plone site').click()
    br.getControl(name = 'site_id').value = 'recensio'
    br.getControl(name = 'extension_ids:list', index=2).value = profile
    br.getControl('Create Plone Site').click()
    print "Plone site created"
Пример #4
0
def updateTranslations(ignore):
    br = Browser('http://transifex.syslab.com')
    try:
        br.getControl(name='username').value = sys.argv[1]
        if len(sys.argv) < 3:
            import getpass
            br.getControl(name='password').value = getpass.getpass()
        else:
            br.getControl(name='password').value = sys.argv[2]
    except IndexError:
        print "Usage: %s [Your Transifex username] [Your Transifex password]"
        return 1
    br.getControl('Sign in').click()
    for domain, url_tmpl in (('recensio', 'http://transifex.syslab.com/projects/p/recensio/resource/recensiopot/l/%s/download/'), ('plone', 'http://transifex.syslab.com/projects/p/recensio/resource/plonepot/l/%s/download/')):
      for lang in ('de', 'en', 'fr'):
        print "Getting %s for %s" % (domain, lang)
        br.open(url_tmpl % lang)
        file(pkg_resources.resource_filename(__name__, 'locales/%s/LC_MESSAGES/%s.po' % (lang, domain)), 'w').write(br.contents)
Пример #5
0
def reset():
    try:
        host = sys.argv[1]
        user = sys.argv[2]
        passwd = sys.argv[3]
        additional_profiles = sys.argv[4:]
    except:
        pass
    br = Browser()
    br.mech_browser.set_handle_robots(False)
    br.open(sys.argv[1])
    base64string = base64.encodestring('%s:%s' % (user, passwd))[:-1]
    br.addHeader('Authorization', 'Basic %s' % base64string)
    br.reload()
    reloadProfiles(br, host, additional_profiles)
    resetCatalog(br, host)
Пример #6
0
def followLink():
    try:
        while True:
            print 1
            url, country = link_queue.get(False, 1)
            print 2
            browser = Browser()
            print 3
            browser.open(url)
            print 4
            browser.getLink('Company Size').click()
            print 5
            browser.getLink('Sector Type').click()
            print 6, browser.url
            if not country:
                for i in range(60):
                    link_queue.put((url + '/%03i' % i, True))

    except Queue.Empty:
        pass
Пример #7
0
            print 3
            browser.open(url)
            print 4
            browser.getLink('Company Size').click()
            print 5
            browser.getLink('Sector Type').click()
            print 6, browser.url
            if not country:
                for i in range(60):
                    link_queue.put((url + '/%03i' % i, True))

    except Queue.Empty:
        pass
    
if __name__ == '__main__':
    browser = Browser()
    browser.open(start_url)
    soup = BeautifulSoup(browser.contents.decode('utf-8').encode('ascii', 'replace'))
    all_links = soup.find('div', {'class' : 'surveyanswers'}).findAll('a')
    for link in all_links:
        link_queue.put((link['href'], False))

    processes = 1
    pool = Pool(processes=processes)
    for i in range(processes):
        pool.apply_async(followLink)
    performance = range(10)
    while not link_queue.empty():
        time.sleep(1)
        size = link_queue.qsize()
        performance.append(size)
 def test_form(self):
     url = 'http://osha.europa.eu/en/campaigns/hw2008/sign/index_html'
     browser = Browser()
     browser.open(url)
     self.assertTrue('Online Application Form' in browser.contents)
 def test_formSubmission(self):
     url = 'http://osha.europa.eu/scripts/signcharter?txtLanguage=en&txtOrganisation=test&txtAddress=test&txtPostalcode=test&txtCity=test&selCountry=UK&txtFirstname=test&txtLastname=test&txtFunction=&[email protected]&txtTelephone=test&txtOther=&Submit=SUBMIT'
     browser = Browser()
     browser.open(url)
     self.assertTrue('Healthy Workplaces - Good for you. Good for business.' in browser.contents)