Exemplo n.º 1
0
def download_ipa(uuid: str, redirect: bool = False, download_id: str = ""):
    _user = UserInfo.objects.get(uuid=uuid)
    _info = IosAccountInfo.objects.get(account=_user.account)

    filepath = "income/%s/%s_%s.ipa" % (_user.project, _info.team_id,
                                        _info.devices_num)
    if redirect:
        return HttpResponseRedirect(static_entry(filepath))
    else:
        if not download_id:
            download_id = random_str(32)
        __download_process[download_id] = 0
        __download_total[download_id] = os.path.getsize(
            os.path.join("static", filepath))

        def file_iterator(chunk_size=4 * 1024):
            with open(os.path.join("static", filepath), mode="rb") as fin:
                num = 0
                while True:
                    # todo: 不允许相同的多个下载任务

                    c = fin.read(chunk_size)
                    num += len(c)
                    __download_process[download_id] = num
                    if c:
                        yield c
                    else:
                        break

        rsp = StreamingHttpResponse(file_iterator())
        rsp.set_signed_cookie("download_id", download_id, salt="zhihu")
        return rsp
Exemplo n.º 2
0
def manifest(uuid: str, need_process=True, download_id: str = ""):
    _user = UserInfo.objects.get(uuid=uuid)
    _account = IosAccountInfo.objects.get(account=_user.account)
    _project = IosProjectInfo.objects.get(project=_user.project)
    _app = IosAppInfo.objects.get(sid="%s:%s" % (_user.account, _user.project))
    _comments = str_json(_project.comments)
    content = """\
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>items</key>
        <array>
            <dict>
                <key>assets</key>
                <array>
                    <dict>
                        <key>kind</key>
                        <string>software-package</string>
                        <key>url</key>
                        <string>%(url)s</string>
                    </dict>
                    <dict>
                        <key>kind</key>
                        <string>display-image</string>
                        <key>url</key>
                        <string>%(icon)s</string>
                    </dict>
                    <dict>
                        <key>kind</key>
                        <string>full-size-image</string>
                        <key>url</key>
                        <string>%(icon)s</string>
                    </dict>
                </array>
                <key>metadata</key>
                <dict>
                    <key>bundle-identifier</key>
                    <string>%(app)s</string>
                    <key>bundle-version</key>
                    <string>%(version)s</string>
                    <key>kind</key>
                    <string>software</string>
                    <key>title</key>
                    <string>%(title)s</string>
                </dict>
            </dict>
        </array>
    </dict>
</plist>
""" % {
        "url":
        static_entry("/income/%s/%s_%s.ipa") %
        (_project.project, _account.team_id, _account.devices_num)
        if not need_process else entry(
            "/apple/download_ipa/uuid/%s/download_id/%s" %
            (uuid, download_id or random_str())),
        "uuid":
        uuid,
        "title":
        _comments["name"],
        "icon":
        _comments["icon"],
        "app":
        _app.identifier,
        "version":
        "1.0.0",
    }
    response = HttpResponse(content)
    response['Content-Type'] = 'application/octet-stream; charset=utf-8'
    response["Content-Disposition"] = 'attachment; filename="app.plist"'

    return response
Exemplo n.º 3
0
        {
            'label': 'Users',
            'url': 'auth.user',
            'icon': 'icon-user'
        },

        # Separator
        '-',

        # Custom app and model with permissions
        {
            'label':
            'Secure',
            'permissions':
            'auth.add_user',
            'models': [{
                'label': 'custom-child',
                'permissions': ('auth.add_user', 'auth.add_group')
            }]
        },
    ),
    'LIST_PER_PAGE':
    20
}

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/

STATIC_URL = '/static/' if DEBUG else static_entry("/", follow_proto=True)
STATIC_ROOT = 'static' if DEBUG else '/var/www/html'
Exemplo n.º 4
0
    def human_download(self, _info):
        return """\
<a href="%s">下载ipa</a>
""" % static_entry("/projects/%s/orig.ipa" % _info.project)