Пример #1
0
def login():
    c.clear_cookies()
    c.go('http://icfpcontest.org/icfp10/login')
    c.fv(1, 'j_username', 'Side Effects May Include...')
    c.fv(1, 'j_password', '<redacted>')
    c.submit()
    c.save_cookies('/tmp/icfp.cookie')
Пример #2
0
def fetch(url):
	dom = ''
	o=urlparse.urlparse(url)
	print o.netloc
	cookiefile=os.path.expanduser('~/.cookie.'+dom)
	if os.path.exists(cookiefile):
		load_cookies(cookiefile)
	go('http://www.google.com/ncr')
	print "fetching", url
	save_cookies(cookiefile)
Пример #3
0
 def reset(self):
     self.tool = None
     self.tool_opts = None
     self._hda_id = None
     self._hda_state = None
     self._history_id = None
     self.check_file = None
     if new_history:
         self.get("/history/delete_current")
         tc.save_cookies(self.cookie_jar)
     self.delete_datasets()
Пример #4
0
 def reset(self):
     self.tool = None
     self.tool_opts = None
     self._hda_id = None
     self._hda_state = None
     self._history_id = None
     self.check_file = None
     if new_history:
         self.get("/history/delete_current")
         tc.save_cookies(self.cookie_jar)
     self.delete_datasets()
Пример #5
0
 def __init__(self):
     self.server = server
     self.tool = None
     self.tool_opts = None
     self._hda_id = None
     self._hda_state = None
     self._history_id = None
     self.check_file = None
     self.cookie_jar = os.path.join( var_dir, "cookie_jar" )
     dprint("cookie jar path: %s" % self.cookie_jar)
     if not os.access(self.cookie_jar, os.R_OK):
         dprint("no cookie jar at above path, creating")
         tc.save_cookies(self.cookie_jar)
     tc.load_cookies(self.cookie_jar)
Пример #6
0
 def __init__(self):
     self.server = server
     self.tool = None
     self.tool_opts = None
     self._hda_id = None
     self._hda_state = None
     self._history_id = None
     self.check_file = None
     self.cookie_jar = os.path.join(var_dir, "cookie_jar")
     dprint("cookie jar path: %s" % self.cookie_jar)
     if not os.access(self.cookie_jar, os.R_OK):
         dprint("no cookie jar at above path, creating")
         tc.save_cookies(self.cookie_jar)
     tc.load_cookies(self.cookie_jar)
Пример #7
0
 def login(self, user, pw):
     self.get("/user/login")
     tc.fv("1", "login", user)
     tc.fv("1", "password", pw)
     tc.submit("Login")
     tc.code(200)
     if len(tc.get_browser().get_all_forms()) > 0:
         # uh ohs, fail
         p = userParser()
         p.feed(tc.browser.get_html())
         if p.bad_pw:
             raise Exception("Password is incorrect")
         else:
             raise Exception("Unknown error logging in")
     tc.save_cookies(self.cookie_jar)
Пример #8
0
 def login(self, user, pw):
     self.get("/user/login")
     tc.fv("1", "login", user)
     tc.fv("1", "password", pw)
     tc.submit("Login")
     tc.code(200)
     if len(tc.get_browser().get_all_forms()) > 0:
         # uh ohs, fail
         p = userParser()
         p.feed(tc.browser.get_html())
         if p.bad_pw:
             raise Exception("Password is incorrect")
         else:
             raise Exception("Unknown error logging in")
     tc.save_cookies(self.cookie_jar)
Пример #9
0
 def reset(self):
     self.tool = None
     self.tool_opts = None
     self.id = None
     self.status = None
     self.check_file = None
     self.delete_datasets()
     self.get("/root/history")
     p = didParser()
     p.feed(tc.browser.get_html())
     if len(p.dids) > 0:
         print "Remaining datasets ids:", " ".join(p.dids)
         raise Exception, "History still contains datasets after attempting to delete them"
     if new_history:
         self.get("/history/delete_current")
         tc.save_cookies(self.cookie_jar)
 def reset(self):
     self.tool = None
     self.tool_opts = None
     self.id = None
     self.status = None
     self.check_file = None
     self.delete_datasets()
     self.get("/root/history")
     p = didParser()
     p.feed(tc.browser.get_html())
     if len(p.dids) > 0:
         print "Remaining datasets ids:", " ".join( p.dids )
         raise Exception, "History still contains datasets after attempting to delete them"
     if new_history:
         self.get("/history/delete_current")
         tc.save_cookies(self.cookie_jar)
Пример #11
0
 def __init__(self):
     self.server = server
     self.handler = handler
     self.waited = -1
     self.tool = 'echo_' + handler
     self._hda_id = None
     self._hda_state = None
     self._history_id = None
     if not self.server.startswith('http'):
         self.server = 'http://' + self.server
     self.cookie_jar = os.path.join(var_dir, "cookie_jar")
     dprint("cookie jar path: %s" % self.cookie_jar)
     if not os.access(self.cookie_jar, os.R_OK):
         dprint("no cookie jar at above path, creating")
         tc.save_cookies(self.cookie_jar)
     tc.load_cookies(self.cookie_jar)
     self.opener = build_opener(HTTPCookieProcessor(tc.get_browser().cj))
Пример #12
0
 def __init__(self):
     self.server = server
     self.handler = handler
     self.waited = -1
     self.tool = 'echo_' + handler
     self._hda_id = None
     self._hda_state = None
     self._history_id = None
     if not self.server.startswith('http'):
         self.server = 'http://' + self.server
     self.cookie_jar = os.path.join(var_dir, "cookie_jar")
     dprint("cookie jar path: %s" % self.cookie_jar)
     if not os.access(self.cookie_jar, os.R_OK):
         dprint("no cookie jar at above path, creating")
         tc.save_cookies(self.cookie_jar)
     tc.load_cookies(self.cookie_jar)
     self.opener = build_opener(HTTPCookieProcessor(tc.get_browser().cj))
Пример #13
0
 def login(self, user, pw):
     self.get("/user/login")
     tc.fv("1", "email", user)
     tc.fv("1", "password", pw)
     tc.submit("Login")
     tc.code(200)
     if len(tc.get_browser().get_all_forms()) > 0:
         # uh ohs, fail
         p = userParser()
         p.feed(tc.browser.get_html())
         if p.no_user:
             dprint("user does not exist, will try creating")
             self.create_user(user, pw)
         elif p.bad_pw:
             raise Exception, "Password is incorrect"
         else:
             raise Exception, "Unknown error logging in"
     tc.save_cookies(self.cookie_jar)
Пример #14
0
 def login(self, user, pw):
     self.get("/user/login")
     tc.fv("1", "email", user)
     tc.fv("1", "password", pw)
     tc.submit("Login")
     tc.code(200)
     if len(tc.get_browser().get_all_forms()) > 0:
         # uh ohs, fail
         p = userParser()
         p.feed(tc.browser.get_html())
         if p.no_user:
             dprint("user does not exist, will try creating")
             self.create_user(user, pw)
         elif p.bad_pw:
             raise Exception("Password is incorrect")
         else:
             raise Exception("Unknown error logging in")
     tc.save_cookies(self.cookie_jar)
Пример #15
0
def set_cookie(domain,
               name,
               value,
               expires=(datetime.now() +
                        timedelta(days=365)).strftime("%Y-%m-%d %H:%M:%S")):
    """ idea from http://www.mail-archive.com/[email protected]/msg00951.html """
    cookie_file = "cookies.txt"

    params = dict(domain=domain, name=name, value=value, expires=expires)

    cmd.save_cookies(cookie_file)
    cookie = open(cookie_file, "a+")
    cookie.write('Set-Cookie3: %(name)s=%(value)s; '\
                 'path="/"; domain="%(domain)s"; path_spec; domain_dot; '\
                 'expires="%(expires)s"; version=0' % params)
    cookie.flush()
    cmd.load_cookies(cookie_file)
    os.unlink(cookie_file)