当前位置: 首页>>代码示例>>Python>>正文


Python MozillaCookieJar.save方法代码示例

本文整理汇总了Python中http.cookiejar.MozillaCookieJar.save方法的典型用法代码示例。如果您正苦于以下问题:Python MozillaCookieJar.save方法的具体用法?Python MozillaCookieJar.save怎么用?Python MozillaCookieJar.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在http.cookiejar.MozillaCookieJar的用法示例。


在下文中一共展示了MozillaCookieJar.save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from http.cookiejar import MozillaCookieJar [as 别名]
# 或者: from http.cookiejar.MozillaCookieJar import save [as 别名]
    def __init__(self, mobile, password=None, status='0',
                 cachefile='Fetion.cache', cookiesfile=''):
        '''登录状态:
        在线:400 隐身:0 忙碌:600 离开:100
        '''
        if cachefile:
            self.cache = Cache(cachefile)

        if not cookiesfile:
            cookiesfile = '%s.cookies' % mobile

        cookiejar = MozillaCookieJar(filename=cookiesfile)
        if not os.path.isfile(cookiesfile):
            open(cookiesfile, 'w').write(MozillaCookieJar.header)

        cookiejar.load(filename=cookiesfile)

        cookie_processor = HTTPCookieProcessor(cookiejar)

        self.opener = build_opener(cookie_processor,
                                   HTTPHandler)
        self.mobile, self.password = mobile, password
        if not self.alive():
            self._login()
            cookiejar.save()

        self.changestatus(status)
开发者ID:Fowler-Zhang,项目名称:PyWapFetion,代码行数:29,代码来源:Fetion.py

示例2: Session

# 需要导入模块: from http.cookiejar import MozillaCookieJar [as 别名]
# 或者: from http.cookiejar.MozillaCookieJar import save [as 别名]
class Session(object):
    def __init__(self, app_name, app_version, data_path, **kwargs):
        self.app_name = app_name
        self.app_version = app_version

        if not data_path or not os.path.isdir(data_path):
            raise Exception('invalid data_path: %s' % data_path)

        self.cookie_jar = MozillaCookieJar(os.path.join(data_path, default.COOKIES_FILENAME))
        try:
            self.cookie_jar.load()
        except EnvironmentError:
            pass

        self.opener = build_opener(
            HTTPRedirectHandler(),
            HTTPCookieProcessor(self.cookie_jar))

        super(Session, self).__init__(**kwargs)

    def open(self, request, default_charset=None):
        request.add_header('User-Agent', util.user_agent(self.app_name, self.app_version))

        system_string = json.dumps(util.system_info(self.app_name, self.app_version))
        request.add_header('X-Sputnik-System', system_string)

        r = self.opener.open(request)

        if hasattr(r.headers, 'get_content_charset'):  # py3
            charset = r.headers.get_content_charset() or default_charset
        elif hasattr(r.headers, 'getparam'):  # py2
            charset = r.headers.getparam('charset') or default_charset
        else:
            charset = default_charset

        if charset is None:
            return r
        return codecs.getreader(charset)(r)

    def __del__(self):
        if hasattr(self, 'cookie_jar'):
            self.cookie_jar.save()
开发者ID:dav009,项目名称:sputnik,代码行数:44,代码来源:session.py

示例3: login

# 需要导入模块: from http.cookiejar import MozillaCookieJar [as 别名]
# 或者: from http.cookiejar.MozillaCookieJar import save [as 别名]
    def login(self, pixiv_id='614634238', password='spider614634238'):
        cookie = MozillaCookieJar(self.cookiesFile)
        self.build_opener(cookie, self.use_proxy)
        print('Login...')

        page = self.get_page_data(self.loginUrl)
        pattern = compile('name="post_key"\s*value="(.*?)"')
        post_key = search(pattern, page).group(1)

        post_value = {
            'pixiv_id': pixiv_id,
            'password': password,
            'g_recaptcha_response': '',
            'post_key': post_key,
            'source': 'pc'
        }
        page = self.get_page_data(self.loginUrl, post_value)
        if search('error-msg-list', page):
            print('Login failed.')
            raise SystemExit(1)
        cookie.save(ignore_discard=True, ignore_expires=True)
开发者ID:akrisrn,项目名称:pixdog,代码行数:23,代码来源:pixiv_module.py

示例4: Session

# 需要导入模块: from http.cookiejar import MozillaCookieJar [as 别名]
# 或者: from http.cookiejar.MozillaCookieJar import save [as 别名]
class Session(Base):
    def __init__(self, data_path, **kwargs):
        if not validation.is_data_path(data_path):
            raise Exception('invalid data_path: %s' % data_path)

        self.cookie_jar = MozillaCookieJar(os.path.join(data_path, default.COOKIES_FILENAME))
        try:
            self.cookie_jar.load()
        except EnvironmentError:
            pass

        self.opener = build_opener(
            HTTPRedirectHandler(),
            HTTPCookieProcessor(self.cookie_jar))

        super(Session, self).__init__(**kwargs)

    def open(self, request, default_charset=None):
        request.add_header('User-Agent', self.s.user_agent())
        if self.s.name:
            request.add_header('X-Sputnik-Name', self.s.name)
        if self.s.version:
            request.add_header('X-Sputnik-Version', self.s.version)

        r = self.opener.open(request)

        if hasattr(r.headers, 'get_content_charset'):  # py3
            charset = r.headers.get_content_charset() or default_charset
        elif hasattr(r.headers, 'getparam'):  # py2
            charset = r.headers.getparam('charset') or default_charset
        else:
            charset = default_charset

        if charset is None:
            return r
        return codecs.getreader(charset)(r)

    def __del__(self):
        if hasattr(self, 'cookie_jar'):
            self.cookie_jar.save()
开发者ID:EricSchles,项目名称:sputnik,代码行数:42,代码来源:session.py

示例5: ScholarQuerier

# 需要导入模块: from http.cookiejar import MozillaCookieJar [as 别名]
# 或者: from http.cookiejar.MozillaCookieJar import save [as 别名]
class ScholarQuerier(object):

    """
    ScholarQuerier instances can conduct a search on Google Scholar
    with subsequent parsing of the resulting HTML content.  The
    articles found are collected in the articles member, a list of
    ScholarArticle instances.
    """

    # Default URLs for visiting and submitting Settings pane, as of 3/14
    GET_SETTINGS_URL = ScholarConf.SCHOLAR_SITE + '/scholar_settings?' \
        + 'sciifh=1&hl=en&as_sdt=0,5'

    SET_SETTINGS_URL = ScholarConf.SCHOLAR_SITE + '/scholar_setprefs?' \
        + 'q=' \
        + '&scisig=%(scisig)s' \
        + '&inststart=0' \
        + '&as_sdt=1,5' \
        + '&as_sdtp=' \
        + '&num=%(num)s' \
        + '&scis=%(scis)s' \
        + '%(scisf)s' \
        + '&hl=en&lang=all&instq=&inst=569367360547434339&save='

    # Older URLs:
    # ScholarConf.SCHOLAR_SITE + '/scholar?q=%s&hl=en&btnG=Search&as_sdt=2001&as_sdtp=on

    class Parser(ScholarArticleParser120726):
        def __init__(self, querier):
            ScholarArticleParser120726.__init__(self)
            self.querier = querier

        def handle_article(self, art):
            self.querier.add_article(art)

    def __init__(self):
        self.articles = []
        self.query = None
        self.cjar = MozillaCookieJar()

        # If we have a cookie file, load it:
        if ScholarConf.COOKIE_JAR_FILE and \
           os.path.exists(ScholarConf.COOKIE_JAR_FILE):
            try:
                self.cjar.load(ScholarConf.COOKIE_JAR_FILE,
                               ignore_discard=True)
                ScholarUtils.log('info', 'loaded cookies file')
            except Exception as msg:
                ScholarUtils.log('warn', 'could not load cookies file: %s' % msg)
                self.cjar = MozillaCookieJar() # Just to be safe

        self.opener = build_opener(HTTPCookieProcessor(self.cjar))
        self.settings = None # Last settings object, if any

    def apply_settings(self, settings):
        """
        Applies settings as provided by a ScholarSettings instance.
        """
        if settings is None or not settings.is_configured():
            return True

        self.settings = settings

        # This is a bit of work. We need to actually retrieve the
        # contents of the Settings pane HTML in order to extract
        # hidden fields before we can compose the query for updating
        # the settings.
        html = self._get_http_response(url=self.GET_SETTINGS_URL,
                                       log_msg='dump of settings form HTML',
                                       err_msg='requesting settings failed')
        if html is None:
            return False

        # Now parse the required stuff out of the form. We require the
        # "scisig" token to make the upload of our settings acceptable
        # to Google.
        soup = BeautifulSoup(html)

        tag = soup.find(name='form', attrs={'id': 'gs_settings_form'})
        if tag is None:
            ScholarUtils.log('info', 'parsing settings failed: no form')
            return False

        tag = tag.find('input', attrs={'type':'hidden', 'name':'scisig'})
        if tag is None:
            ScholarUtils.log('info', 'parsing settings failed: scisig')
            return False

        urlargs = {'scisig': tag['value'],
                   'num': settings.per_page_results,
                   'scis': 'no',
                   'scisf': ''}

        if settings.citform != 0:
            urlargs['scis'] = 'yes'
            urlargs['scisf'] = '&scisf=%d' % settings.citform

        html = self._get_http_response(url=self.SET_SETTINGS_URL % urlargs,
                                       log_msg='dump of settings result HTML',
                                       err_msg='applying setttings failed')
#.........这里部分代码省略.........
开发者ID:VigTech,项目名称:Vigtech-Scholar,代码行数:103,代码来源:scholar.py

示例6: __init__

# 需要导入模块: from http.cookiejar import MozillaCookieJar [as 别名]
# 或者: from http.cookiejar.MozillaCookieJar import save [as 别名]
class PowerSchool:
    """This class manages cookies for accessing PowerSchool, as well as
    providing facilities for retrieving pages."""
    def __init__(self,host=DEFAULT_HOST,cookiejar=None,debug=False):
        """Params:
        host: the protocol, hostname, and port (without a trailing slash)
            that is the root of the PowerSchool url.
        cookiejar: An http.cookiejar.CookieJar or subclass. If a FileCookieJar,
            cookies will be saved after every request.
        debug: sets verbose mode"""
        self.DEBUG = debug
        self.host = host
        self.setCookieJar(cookiejar)

    def setCookieJar(self,cookiejar):
        """Changes the CookieJar used to manage the session.
        Existing cookies will not be transferred.
        
        Returns: the old CookieJar"""
        tmpcookies = getattr(self,"cookies",None)
        if type(cookiejar) == str:
            self.cookies = MozillaCookieJar(cookiejar)
            if os.path.exists(cookiejar):
                self.cookies.load(ignore_discard=True)
        else:
            self.cookies = cookiejar
        self.opener = build_opener(HTTPCookieProcessor(self.cookies))
        return tmpcookies

    def _get_page(self,url,data=None):
        start = time.time()
        page = (self.opener.open(url,urlencode(data).encode()) if data else
                self.opener.open(url))
        if self.DEBUG:
            print("Request time: {}".format(time.time()-start))
        if hasattr(self.cookies,"save"):
            self.cookies.save(ignore_discard=True)
        return page

    def _read_page(self,url,data=None):
        self.__last_page = self._get_page(url,data).read().decode()
        if self.DEBUG:
            fd = open("/tmp/pschool-debug-temp.html","w")
            fd.write(self.__last_page)
            fd.close()
        return self.__last_page
        
    def _get_url(self,url):
        return self.host + (url if url.startswith("/") else "/"+url)

    def _check_for_logout(self):
        if self.__last_page.find("Student and Parent Sign In") > -1:
            raise LoggedOut()

    def login(self,username,password):
        """Login to a PowerSchool session using the supplied credentials."""
        data = self._read_page(self._get_url("/public/"))
        form = dict(re.findall(r'<input .+?name="(.+?)".+?value="(.*?)".+?>',
                               data, re.MULTILINE|re.IGNORECASE))
        form["account"] = username
        form["ldappassword"] = password
        pskey = form["contextData"].encode()
        password = password.encode()
    
        b64pw = b64encode(md5(password).digest()).decode().rstrip("=")
        form["pw"] = hmac.new(pskey,b64pw.encode()).hexdigest()
        form["dbpw"] = hmac.new(pskey,password.lower()).hexdigest()

        self._read_page(self._get_url("/guardian/home.html"),form)
        try:
            self._check_for_logout()
        except LoggedOut:
            raise InvalidCredentials

    def get(self,page="Main",args=(),**kwargs):
        """Retrieves data for and constructs the supplied Page class."""
        if type(page) == str:
            page = getattr(pages,page,None)
            if not page:
                raise TypeError("Invalid page")
        data = self._read_page(self._get_url(page.get_url(*args,**kwargs)))
        self._check_for_logout()
        return page(data,self,(args,kwargs))
开发者ID:baryon5,项目名称:powerschool,代码行数:85,代码来源:__init__.py

示例7: ScholarQuerier

# 需要导入模块: from http.cookiejar import MozillaCookieJar [as 别名]
# 或者: from http.cookiejar.MozillaCookieJar import save [as 别名]
class ScholarQuerier(object):

    """
    ScholarQuerier instances can conduct a search on Google Scholar
    with subsequent parsing of the resulting HTML content.  The
    articles found are collected in the articles member, a list of
    ScholarArticle instances.
    """
    SCHOLAR_QUERY_URL = ScholarConf.SCHOLAR_SITE + '/scholar?' \
        + 'as_q=%(words)s' \
        + '&as_epq=%(phrase)s' \
        + '&as_oq=%(words_some)s' \
        + '&as_eq=%(words_none)s' \
        + '&as_occt=%(scope)s' \
        + '&as_sauthors=%(authors)s' \
        + '&as_publication=%(pub)s' \
        + '&as_ylo=%(ylo)s' \
        + '&as_yhi=%(yhi)s' \
        + '&btnG=&hl=en&as_sdt=0,5&num=%(num)s'

    # Default URLs for visiting and submitting Settings pane, as of 3/14
    GET_SETTINGS_URL = ScholarConf.SCHOLAR_SITE + '/scholar_settings?' \
        + 'sciifh=1&hl=en&as_sdt=0,5'

    SET_SETTINGS_URL = ScholarConf.SCHOLAR_SITE + '/scholar_setprefs?' \
        + 'q=' \
        + '&scisig=%(scisig)s' \
        + '&inststart=0' \
        + '&as_sdt=1,5' \
        + '&as_sdtp=' \
        + '&num=%(num)s' \
        + '&scis=%(scis)s' \
        + '%(scisf)s' \
        + '&hl=en&lang=all&instq=&inst=569367360547434339&save='

    # Older URLs:
    # ScholarConf.SCHOLAR_SITE + '/scholar?q=%s&hl=en&btnG=Search&as_sdt=2001&as_sdtp=on

    class Parser(ScholarArticleParser120726):
        def __init__(self, querier):
            ScholarArticleParser120726.__init__(self)
            self.querier = querier

        def handle_article(self, art):
            self.querier.add_article(art)

    def __init__(self):
        self.articles = []
        self.query = None
        self.cjar = MozillaCookieJar()

        # If we have a cookie file, load it:
        if ScholarConf.COOKIE_JAR_FILE and \
           os.path.exists(ScholarConf.COOKIE_JAR_FILE):
            try:
                self.cjar.load(ScholarConf.COOKIE_JAR_FILE,
                               ignore_discard=True)
                ScholarUtils.log('debug', 'loaded cookies file')
            except Exception as msg:
                ScholarUtils.log('warn', 'could not load cookies file: %s' % msg)
                self.cjar = MozillaCookieJar() # Just to be safe

        self.opener = build_opener(HTTPCookieProcessor(self.cjar))
        self.settings = None # Last settings object, if any

    def apply_settings(self, settings):
        """
        Applies settings as provided by a ScholarSettings instance.
        """
        if settings is None or not settings.is_configured():
            return True

        self.settings = settings

        # This is a bit of work. We need to actually retrieve the
        # contents of the Settings pane HTML in order to extract
        # hidden fields before we can compose the query for updating
        # the settings.
        try:
            req = Request(url=self.GET_SETTINGS_URL,
                          headers={'User-Agent': ScholarConf.USER_AGENT})
            hdl = self.opener.open(req)
            html = hdl.read()
        except Exception as err:
            ScholarUtils.log('debug', 'requesting settings failed: %s' % err)
            return False

        # Now parse the required stuff out of the form. We require the
        # "scisig" token to make the upload of our settings acceptable
        # to Google.
        soup = BeautifulSoup(html)

        tag = soup.find(name='form', attrs={'id': 'gs_settings_form'})
        if tag is None:
            ScholarUtils.log('debug', 'parsing settings failed: no form')
            return False

        tag = tag.find('input', attrs={'type':'hidden', 'name':'scisig'})
        if tag is None:
            ScholarUtils.log('debug', 'parsing settings failed: scisig')
#.........这里部分代码省略.........
开发者ID:Rygbee,项目名称:semantic-search-api,代码行数:103,代码来源:scholar.py

示例8: BaseClient

# 需要导入模块: from http.cookiejar import MozillaCookieJar [as 别名]
# 或者: from http.cookiejar.MozillaCookieJar import save [as 别名]
class BaseClient(object):
    """
    Базовый класс для работы с удалённым API
    """

    username = None
    password = None
    url      = 'http://localhost:8000/api/'
    headers  = {
        "Content-type": "application/json",
        "Accept": "application/json",
        "Accept-Encoding": "gzip, deflate",
    }
    timeout  = 10000
    cookiejar = None
    print_info = False
    code_page = 'utf-8'
    use_basic_auth = False


    def __init__(self, cookie_filename=None, **kwargs):

        for key, val in kwargs.items():
            setattr(self, key, val)

        if cookie_filename:
            self.set_cookiejar(cookie_filename)

    def set_cookiejar(self, name):
        self.cookiejar = MozillaCookieJar(name)
        try:
            self.cookiejar.load()
        except IOError:
            self.cookiejar.save()

    def get_request(self, data):
        """
        Возвращает новый объект запроса.
        """

        params = urlencode({'jsonData': data})
        params = params.encode('ascii')
        
        headers = {}
        headers.update(self.headers)
        if self.use_basic_auth and self.username and self.password:
            s = '%s:%s' % (self.username, self.password)
            if six.PY3:
                b = bytes(s, 'utf-8')
            else:
                b = bytes(s.encode('utf-8'))

            headers['Authorization'] = b'Basic ' + base64.b64encode(b)
        
        request = Request(url=self.url, data=params, headers=headers)

        return request

    def get_opener(self):
        """
        Возвращает новый обработчик запроса с необходимыми процессорами.
        """
        args = ()

        if not self.cookiejar is None:
            cookiehand = HTTPCookieProcessor(self.cookiejar)
            args += (cookiehand,)

        return build_opener(*args)


    def get_response(self, request):
        """
        Возвращает новый обработчик запроса и устанавливает куки.
        """

        opener = self.get_opener()

        try:
            response = opener.open(request, timeout=self.timeout)
        except IOError as e:
            raise e

        if not self.cookiejar is None:
            self.cookiejar.save()

        return response

    def get_result(self, data):
        """
        Запрашивает данные из API
        """

        if self.print_info:
            print('Kwargs: %s' % data.get('kwargs', {}))

        jsondata = json.dumps(data)

        request = self.get_request(jsondata)

#.........这里部分代码省略.........
开发者ID:Cophy08,项目名称:django-quickapi,代码行数:103,代码来源:client.py

示例9: ScholarQuerier

# 需要导入模块: from http.cookiejar import MozillaCookieJar [as 别名]
# 或者: from http.cookiejar.MozillaCookieJar import save [as 别名]
class ScholarQuerier(object):

    """
    ScholarQuerier instances can conduct a search on Google Scholar
    with subsequent parsing of the resulting HTML content.  The
    articles found are collected in the articles member, a list of
    ScholarArticle instances.
    """

    # Default URLs for visiting and submitting Settings pane, as of 3/14
    GET_SETTINGS_URL = ScholarConf.SCHOLAR_SITE + "/scholar_settings?" + "sciifh=1&hl=en&as_sdt=0,5"

    SET_SETTINGS_URL = (
        ScholarConf.SCHOLAR_SITE
        + "/scholar_setprefs?"
        + "q="
        + "&scisig=%(scisig)s"
        + "&inststart=0"
        + "&as_sdt=1,5"
        + "&as_sdtp="
        + "&num=%(num)s"
        + "&scis=%(scis)s"
        + "%(scisf)s"
        + "&hl=en&lang=all&instq=&inst=569367360547434339&save="
    )

    # Older URLs:
    # ScholarConf.SCHOLAR_SITE + '/scholar?q=%s&hl=en&btnG=Search&as_sdt=2001&as_sdtp=on

    class Parser(ScholarArticleParser120726):
        def __init__(self, querier):
            ScholarArticleParser120726.__init__(self)
            self.querier = querier

        def handle_num_results(self, num_results):
            if self.querier is not None and self.querier.query is not None:
                self.querier.query["num_results"] = num_results

        def handle_article(self, art):
            self.querier.add_article(art)

    def __init__(self):
        self.articles = []
        self.query = None
        self.cjar = MozillaCookieJar()

        # If we have a cookie file, load it:
        if ScholarConf.COOKIE_JAR_FILE and os.path.exists(ScholarConf.COOKIE_JAR_FILE):
            try:
                self.cjar.load(ScholarConf.COOKIE_JAR_FILE, ignore_discard=True)
                ScholarUtils.log("info", "loaded cookies file")
            except Exception as msg:
                ScholarUtils.log("warn", "could not load cookies file: %s" % msg)
                self.cjar = MozillaCookieJar()  # Just to be safe

        self.opener = build_opener(HTTPCookieProcessor(self.cjar))
        self.settings = None  # Last settings object, if any

    def apply_settings(self, settings):
        """
        Applies settings as provided by a ScholarSettings instance.
        """
        if settings is None or not settings.is_configured():
            return True

        self.settings = settings

        # This is a bit of work. We need to actually retrieve the
        # contents of the Settings pane HTML in order to extract
        # hidden fields before we can compose the query for updating
        # the settings.
        html = self._get_http_response(
            url=self.GET_SETTINGS_URL, log_msg="dump of settings form HTML", err_msg="requesting settings failed"
        )
        if html is None:
            return False

        # Now parse the required stuff out of the form. We require the
        # "scisig" token to make the upload of our settings acceptable
        # to Google.
        soup = BeautifulSoup(html)

        tag = soup.find(name="form", attrs={"id": "gs_settings_form"})
        if tag is None:
            ScholarUtils.log("info", "parsing settings failed: no form")
            return False

        tag = tag.find("input", attrs={"type": "hidden", "name": "scisig"})
        if tag is None:
            ScholarUtils.log("info", "parsing settings failed: scisig")
            return False

        urlargs = {"scisig": tag["value"], "num": settings.per_page_results, "scis": "no", "scisf": ""}

        if settings.citform != 0:
            urlargs["scis"] = "yes"
            urlargs["scisf"] = "&scisf=%d" % settings.citform

        html = self._get_http_response(
            url=self.SET_SETTINGS_URL % urlargs,
#.........这里部分代码省略.........
开发者ID:dkoes,项目名称:Open-Source-Molecular-Modelling,代码行数:103,代码来源:scholar.py

示例10: Aurploader

# 需要导入模块: from http.cookiejar import MozillaCookieJar [as 别名]
# 或者: from http.cookiejar.MozillaCookieJar import save [as 别名]

#.........这里部分代码省略.........
      name, ver, rel = pkg.rsplit('-', 2)
    except ValueError:
      raise AurploaderError('unexpected filename format: {}\nexpected <pkgname>-<pkgver>-<pkgrel>.src.<ext>'.format(fname))

    if category not in self.categories:
      category = None
    if category is None:
      pkginfo = self.get_info(name)
      if pkginfo:
        category = int(pkginfo['CategoryID'])

    if category is None or not auto_category:
      category = self.prompt_categories(name, default_category=category)

    # This is not an error. A user may abort the upload by entering "x" at the
    # category prompt.
    if category is None:
      return

    cmd = [
      '/usr/bin/curl',
      '-#',
      '-H', 'Expect:',
      '-b', self.cookiejar_path,
      '-c', self.cookiejar_path,
      '-F', 'category={}'.format(category),
      '-F', '[email protected]{}'.format(fpath),
      '-F', 'pkgsubmit=1',
      '-F', 'token={}'.format(self.token)
    ]

    cmd.append(PKGSUBMIT_URL)

    self.save_cookies()

    with open(os.devnull, 'w') as null:
      p = Popen(cmd, stdout=null)
      e = p.wait()
      if e != 0:
        raise AurploaderError("curl exited with non-zero status ({:d})".format(e))

    self.load_cookies()

    if confirm:
      expected = '{}-{}'.format(ver, rel)
      ttl = self.rpc.ttl
      self.rpc.ttl = 0
      try:
        pkginfo = self.get_info(name)
      finally:
        self.rpc.ttl = ttl
      if not pkginfo or pkginfo['Version'] != expected:
        raise AurploaderError('failed to confirm upload')

    return pkginfo



  def save_cookies(self, path=None):
    """
    Save cookie jar.
    """
    if path is None:
      path = self.cookiejar_path
    if path is None:
      raise AurploaderError('no cookiejar path given')
开发者ID:madjar,项目名称:aurifere,代码行数:70,代码来源:Aurploader.py


注:本文中的http.cookiejar.MozillaCookieJar.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。