Пример #1
0
def ReadRepoLocation():
    """
    This method reutrn a tuple of two strings: "name of the current repo" and
    "repository location".
    """
    if bpio.Linux() or bpio.Mac():
        repo_file = os.path.join(bpio.getExecutableDir(), 'repo')
        if os.path.isfile(repo_file):
            src = bpio.ReadTextFile(repo_file)
            if src:
                try:
                    return src.split('\n')[0].strip(), src.split(
                        '\n')[1].strip()
                except:
                    lg.exc()
        return 'sources', 'https://bitdust.io/download/'
    src = strng.to_bin(bpio.ReadTextFile(settings.RepoFile())).strip()
    if not src:
        return settings.DefaultRepo(), settings.DefaultRepoURL(
            settings.DefaultRepo())
    l = src.split('\n')
    if len(l) < 2:
        return settings.DefaultRepo(), settings.DefaultRepoURL(
            settings.DefaultRepo())
    return l[0], l[1]
Пример #2
0
def step0():
    lg.out(4, 'os_windows_update.step0')
    global _UpdatingInProgress
    if _UpdatingInProgress:
        lg.out(6, 'os_windows_update.step0  _UpdatingInProgress is True, skip.')
        return

    repo, locationURL = misc.ReadRepoLocation()
    src = bpio.ReadTextFile(settings.RepoFile())
    if src == '':
        bpio.WriteTextFile(settings.RepoFile(), u'%s\n%s' % (repo, locationURL))

    _UpdatingInProgress = True
    d = download_version()
    d.addCallback(step1)
    d.addErrback(fail)