Commit b9f227a8 authored by Thibault Saunier's avatar Thibault Saunier

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.
parent 8745ccc5
...@@ -28,6 +28,7 @@ import subprocess ...@@ -28,6 +28,7 @@ import subprocess
import sys import sys
import tempfile import tempfile
import venv import venv
from urllib.error import URLError
from urllib.parse import urlparse from urllib.parse import urlparse
from urllib.request import urlretrieve from urllib.request import urlretrieve
...@@ -256,14 +257,19 @@ class FlatpakRepos(FlatpakObject): ...@@ -256,14 +257,19 @@ class FlatpakRepos(FlatpakObject):
def add(self, name, flatpakrepo_url, override=True): def add(self, name, flatpakrepo_url, override=True):
flatpakrepo = tempfile.NamedTemporaryFile(mode="w") flatpakrepo = tempfile.NamedTemporaryFile(mode="w")
urlretrieve(flatpakrepo_url, flatpakrepo.name) try:
repo = configparser.ConfigParser() urlretrieve(flatpakrepo_url, flatpakrepo.name)
repo.read(flatpakrepo.name) repo = configparser.ConfigParser()
url = repo["Flatpak Repo"]["Url"] repo.read(flatpakrepo.name)
url = repo["Flatpak Repo"]["Url"]
except URLError:
url = None
same_name = None same_name = None
for tmpname, tmprepo in self.repos.items(): 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 return tmprepo
if name == tmpname: if name == tmpname:
same_name = tmprepo same_name = tmprepo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment