Esempio n. 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]
Esempio n. 2
0
 def _done(x, filename):
     try:
         fin = open(filename, 'rb')
         src = strng.to_text(fin.read())
         fin.close()
     except:
         if output_func:
             output_func('error opening downloaded starter file')
         result.errback(Exception('error opening downloaded starter file'))
         return
     local_filename = os.path.join(GetLocalDir(), settings.WindowsStarterFileName())
     bpio.backup_and_remove(local_filename)
     try:
         os.rename(filename, local_filename)
         lg.out(4, 'os_windows_update.download_and_replace_starter  file %s was updated' % local_filename)
     except:
         lg.out(1, 'os_windows_update.download_and_replace_starter ERROR can not rename %s to %s ' % (filename, local_filename))
         lg.exc()
         result.errback(Exception('can not rename the file ' + filename))
         return
     python27dll_path = os.path.join(GetLocalDir(), 'python27.dll')
     if not os.path.exists(python27dll_path):
         lg.out(4, 'os_windows_update.download_and_replace_starter file "python27.dll" not found download from "%s" repo' % repo)
         url = settings.DefaultRepoURL(repo) + 'python27.dll'
         d = net_misc.downloadHTTP(url, python27dll_path)
         d.addCallback(_done_python27_dll, filename)
         d.addErrback(_fail, filename)
         return
     result.callback(1)