Example #1
0
def get_login_data(login, password, api="icq.com", callback=None):
    if callback is None:
        return simplejson.loads(
            wget("https://api.screenname.%s/auth/clientLogin?f=json" % api, dict(k=ICQ_API_KEY, s=login, pwd=password))
        )
    else:
        return asynchttp.httpopen(
            "https://api.screenname.%s/auth/clientLogin?f=json" % api,
            data=dict(k=ICQ_API_KEY, s=login, pwd=password),
            callback=callback,
        )
Example #2
0
def get_login_cookie(login, password, api="icq.net", api2=None):
    if api2 is None:
        api2 = api
    r = get_login_data(login, password, api2)
    sessionSecret = r["response"]["data"]["sessionSecret"]
    token = r["response"]["data"]["token"]["a"]
    sessionKey = hmac_sha256_base64(sessionSecret, password)
    uri = "https://api.oscar.%s/aim/startOSCARSession" % api

    d = dict(a=token, f="json", k=ICQ_API_KEY, ts=r["response"]["data"]["hostTime"], useTLS=1)

    queryString = WebFormData(d=LazySortedDict(d)).replace("+", "%20")
    hashData = "GET&" + urllib.quote(uri, safe="") + "&" + queryString.encode("url")

    digest = hmac_sha256_base64(hashData, sessionKey)

    url = uri + "?" + queryString + "&sig_sha256=" + digest
    ret = simplejson.loads(wget(url))
    return ret
Example #3
0
def run(args):
    src = path(args.src)
    revs = enumerate_revisions(src)
    dist = path(args.dist)

    feature_pth = dist / args.feature

    from StringIO import StringIO
    from collections import defaultdict
    from util.primitives.structures import oset
    versions = oset()
    groups = defaultdict(list)
    for domain, locale, pofile, catalog, template_version in versioned_pos('.'):
        versions.add(template_version)
        groups[template_version].append((domain, locale, pofile, catalog))

    for template_version in versions:
        plugins = {}
        template_root = feature_pth / template_version
        for domain, locale, pofile, catalog in groups[template_version]:
            revid, revno = revs[src.relpathto(pofile).expand()]
            out_zip = template_root / locale / '-'.join([domain, template_version, locale, str(revno)]) + '.zip'
            if not out_zip.parent.isdir():
                out_zip.parent.makedirs()
            mobuf = StringIO()
            write_mo(mobuf, catalog)
            zbuf = StringIO()
            z = zipfile.ZipFile(zbuf, 'w', zipfile.ZIP_DEFLATED)
            z.writestr('-'.join([domain, locale]) + '.mo', mobuf.getvalue())
            infoyaml = info_yaml(args.feature, domain, locale)
            try:
                infoyaml['name'] = u'%s (%s)' % (babel.Locale(locale).get_display_name('en'),
                                                 babel.Locale(locale).get_display_name(locale))
            except Exception:
                pass
            infoyaml['pot_version'] = template_version
            infoyaml['bzr_revno'] = revno
            infoyaml['bzr_revid'] = revid
            infoyaml['catalog_format'] = 'mo'
            infoyaml_bin = syck.dump(infoyaml)
            z.writestr(INFOYAML, infoyaml_bin)
            z.close()
            zout = zbuf.getvalue()
            with out_zip.open('wb') as out:
                out.write(zout)
            infoyaml_pth =(out_zip.parent/INFOYAML)
            with infoyaml_pth.open('wb') as infoyaml_out:
                infoyaml_out.write(infoyaml_bin)
            plugins[infoyaml['shortname']] = dict(
                                                  meta = httprelpath(template_root.relpathto(infoyaml_pth)),
                                                  dist_types = ZIP_DIST,
                                                  zip = dict(
                                                             location = httprelpath(template_root.relpathto(out_zip))
                                                             )
                                                  )
        idxyaml = template_root / 'index.yaml'
        idxbin = syck.dump(dict(plugins=plugins))
        with idxyaml.open('wb') as idx_out:
            idx_out.write(idxbin)
    update_pth = feature_pth / 'update.yaml'
    with open(update_pth, 'wb') as update_out:
        update_out.write(syck.dump({'all':{'release':httprelpath(feature_pth.relpathto(idxyaml))}}))
    try:
        site_d = syck.load(wget('http://s3.amazonaws.com/update.digsby.com/' + dist.name + '/site.yaml'))
    except Exception:
        traceback.print_exc()
        site_d = {}
    try:
        featurs = site_d['features']
    except KeyError:
        featurs = site_d['features'] = {}
    featurs[args.feature]= {
                           'name':args.name,
                           'url': httprelpath(dist.relpathto(update_pth)),
                           }
    with open(dist / 'site.yaml', 'wb') as site_out:
        site_out.write(syck.dump(site_d))