mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-29 20:34:22 +01:00
Added checking internet connection
This commit is contained in:
parent
2aaaac8497
commit
c13fd993b0
2 changed files with 18 additions and 0 deletions
|
@ -2,6 +2,9 @@
|
|||
Fixed: TypeError: stat() argument 1 must be encoded string without null bytes,
|
||||
not str #100
|
||||
|
||||
Added:
|
||||
- Checkng for the internet connection before downloading files
|
||||
|
||||
3.2.9 - 24/09/2017
|
||||
Fixed:
|
||||
- Strange dependency problem #97
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
|
||||
import os
|
||||
import urllib2
|
||||
import tarfile
|
||||
import subprocess
|
||||
|
||||
|
@ -45,6 +46,7 @@ class Download(object):
|
|||
self.dir_prefix = ""
|
||||
self.downder = self.meta.downder
|
||||
self.downder_options = self.meta.downder_options
|
||||
self._internet_check()
|
||||
|
||||
def start(self):
|
||||
"""Download files using wget or other downloader.
|
||||
|
@ -120,3 +122,16 @@ class Download(object):
|
|||
self.downder_options += certificate
|
||||
if not self.msg.answer() in ["y", "Y"]:
|
||||
raise SystemExit()
|
||||
|
||||
def _internet_check(self):
|
||||
"""Check for internet connection
|
||||
"""
|
||||
url = "".join(self.url)
|
||||
try:
|
||||
f = urllib2.urlopen(url)
|
||||
return f.read()
|
||||
except (urllib2.URLError, ValueError):
|
||||
print("\n{0}slpkg: Error: unable to resolve the internet connection"
|
||||
"{1}\n".format(self.meta.color["RED"],
|
||||
self.meta.color["ENDC"]))
|
||||
raise SystemExit()
|
||||
|
|
Loading…
Add table
Reference in a new issue