[pitivi] flatpak: Allow using env when no network avalaible



commit b9f227a89bf2b2f3d94dd07ac345f731a7786c87
Author: Thibault Saunier <tsaunier igalia com>
Date:   Sun Jul 29 20:57:21 2018 -0400

    flatpak: Allow using env when no network avalaible
    
    I just got a power cut... and without internet access the
    pitivi-flatpak script was not usable. Just assume everything is all
    right if we could not retrieve repo infos.

 build/flatpak/pitivi-flatpak | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/build/flatpak/pitivi-flatpak b/build/flatpak/pitivi-flatpak
index cb7083e8..4444b828 100755
--- a/build/flatpak/pitivi-flatpak
+++ b/build/flatpak/pitivi-flatpak
@@ -28,6 +28,7 @@ import subprocess
 import sys
 import tempfile
 import venv
+from urllib.error import URLError
 from urllib.parse import urlparse
 from urllib.request import urlretrieve
 
@@ -256,14 +257,19 @@ class FlatpakRepos(FlatpakObject):
 
     def add(self, name, flatpakrepo_url, override=True):
         flatpakrepo = tempfile.NamedTemporaryFile(mode="w")
-        urlretrieve(flatpakrepo_url, flatpakrepo.name)
-        repo = configparser.ConfigParser()
-        repo.read(flatpakrepo.name)
-        url = repo["Flatpak Repo"]["Url"]
+        try:
+            urlretrieve(flatpakrepo_url, flatpakrepo.name)
+            repo = configparser.ConfigParser()
+            repo.read(flatpakrepo.name)
+            url = repo["Flatpak Repo"]["Url"]
+        except URLError:
+            url = None
 
         same_name = None
         for tmpname, tmprepo in self.repos.items():
-            if url == tmprepo.url:
+            # If the URL is None (meaning we couldn't retrieve Repo infos)
+            # just check if the repo names match.
+            if url == tmprepo.url or url is None and name == tmpname:
                 return tmprepo
             if name == tmpname:
                 same_name = tmprepo


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]