Exemplo n.º 1
0
 def format_url(self, url, parameters=None):
     #if isinstance(text, unicode):
     #    text = text.encode('utf-8')
     #values = {
     #            'q': text,
     #          }
     query = ''
     if parameters is not None:
         parameters = {name: encoding.encode(value) for name, value in parameters.items()}
         query = '?' + urllib_parse_urlencode(parameters)
     return url + query
Exemplo n.º 2
0
def add_items(opener, folderId, release_name):
    "Add the 12(!) items for a release to the given folder"
    folder_add_url = 'http://subversion.tigris.org/servlets/ProjectDocumentAdd?folderID=%d&action=Add%%20document' % folderId

    if re.match('^\d*\.\d*\.\d*$', release_name):
      status = 'Stable'
    else:
      status = 'Draft'

    md5sums = get_md5sums()

    for ext in ['.zip', '.tar.gz', '.tar.bz2']:
        for deps in ['', '-deps']:
            filename = 'subversion%s-%s%s' % (deps, release_name, ext)
            desc = 'Subversion %s' % release_name
            if deps:
                desc = desc + ' Dependencies'

            params = {
                'name' : filename,
                'status' : status,
                'description' : '%s (MD5: %s)' % (desc, md5sums[filename]),
                'type': 'link',
                'url': 'http://subversion.tigris.org/downloads/%s' % filename,
                'maxDepth': '',
            }

            # Add file
            request = urllib_request_Request(folder_add_url,
                                             urllib_parse_urlencode(params))
            opener.open(request)

            # Add signature
            filename = filename + '.asc'
            params['name'] = filename
            params['description'] = 'PGP signatures for %s' % desc
            params['url'] = 'http://subversion.tigris.org/downloads/%s' % \
                                                                      filename
            request = urllib_request_Request(folder_add_url,
                                             urllib_parse_urlencode(params))
            opener.open(request)
Exemplo n.º 3
0
def add_items(opener, folderId, release_name):
    "Add the 12(!) items for a release to the given folder"
    folder_add_url = 'http://subversion.tigris.org/servlets/ProjectDocumentAdd?folderID=%d&action=Add%%20document' % folderId

    if re.match('^\d*\.\d*\.\d*$', release_name):
        status = 'Stable'
    else:
        status = 'Draft'

    md5sums = get_md5sums()

    for ext in ['.zip', '.tar.gz', '.tar.bz2']:
        for deps in ['', '-deps']:
            filename = 'subversion%s-%s%s' % (deps, release_name, ext)
            desc = 'Subversion %s' % release_name
            if deps:
                desc = desc + ' Dependencies'

            params = {
                'name': filename,
                'status': status,
                'description': '%s (MD5: %s)' % (desc, md5sums[filename]),
                'type': 'link',
                'url': 'http://subversion.tigris.org/downloads/%s' % filename,
                'maxDepth': '',
            }

            # Add file
            request = urllib_request_Request(folder_add_url,
                                             urllib_parse_urlencode(params))
            opener.open(request)

            # Add signature
            filename = filename + '.asc'
            params['name'] = filename
            params['description'] = 'PGP signatures for %s' % desc
            params['url'] = 'http://subversion.tigris.org/downloads/%s' % \
                                                                      filename
            request = urllib_request_Request(folder_add_url,
                                             urllib_parse_urlencode(params))
            opener.open(request)
Exemplo n.º 4
0
def login(username, password, folderId):
    '''Login to tigris.org, using the provided username and password.
       Return the OpenDirector object for future use.'''
    cj = cookielib.CookieJar()
    opener = urllib_request_build_opener(urllib_request_HTTPCookieProcessor(cj))

    folderURL = 'http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=%d' % folderId,
    params = {
        'detour' : folderURL,
        'loginID' : username,
        'password' : password,
      }
    request = urllib_request_Request('http://www.tigris.org/servlets/TLogin',
                                     urllib_parse_urlencode(params))
    # We open the above request, grabbing the appropriate credentials for
    # future interactions.
    opener.open(request)

    return opener
Exemplo n.º 5
0
def login(username, password, folderId):
    '''Login to tigris.org, using the provided username and password.
       Return the OpenDirector object for future use.'''
    cj = cookielib.CookieJar()
    opener = urllib_request_build_opener(
        urllib_request_HTTPCookieProcessor(cj))

    folderURL = 'http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=%d' % folderId,
    params = {
        'detour': folderURL,
        'loginID': username,
        'password': password,
    }
    request = urllib_request_Request('http://www.tigris.org/servlets/TLogin',
                                     urllib_parse_urlencode(params))
    # We open the above request, grabbing the appropriate credentials for
    # future interactions.
    opener.open(request)

    return opener
Exemplo n.º 6
0
def get_url(search_keyword):
    baidu_url_base = 'http://www.baidu.com/s?chrome=UTF-8&'
    url = ''.join(
        [baidu_url_base,
         urllib_parse_urlencode({'wd': search_keyword})])
    return url