Address some pylint issues
This commit is contained in:
parent
bb694671f2
commit
ede631b8e1
@ -21,7 +21,7 @@ class ActionItem:
|
|||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
self.print_progress()
|
self.print_progress()
|
||||||
# Get the result of the future and let it raise exception, if there was any
|
# Get the result of the future and let it raise exception, if there was any
|
||||||
data = future.result()
|
future.result()
|
||||||
self.print_progress('\n')
|
self.print_progress('\n')
|
||||||
|
|
||||||
def print_progress(self, end='\r'):
|
def print_progress(self, end='\r'):
|
||||||
|
@ -8,8 +8,8 @@ from contextlib import contextmanager
|
|||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def lock(lock_file, fail_callback=None):
|
def lock(lock_file, fail_callback=None):
|
||||||
# Open the lock file in append mode first to ensure its existence but not modify any data if it already exists
|
|
||||||
with open(lock_file, 'a'):
|
with open(lock_file, 'a'):
|
||||||
|
# Open the lock file in append mode first to ensure its existence but not modify any data if it already exists
|
||||||
pass
|
pass
|
||||||
# Open the lock file in read + write mode without truncation
|
# Open the lock file in read + write mode without truncation
|
||||||
with open(lock_file, 'r+') as f:
|
with open(lock_file, 'r+') as f:
|
||||||
|
@ -28,7 +28,7 @@ def load_leases():
|
|||||||
leases = [lease.strip().split(None, 1) for lease in f]
|
leases = [lease.strip().split(None, 1) for lease in f]
|
||||||
leases = {ip: hostname for ip, hostname in leases}
|
leases = {ip: hostname for ip, hostname in leases}
|
||||||
mtime = file_mtime
|
mtime = file_mtime
|
||||||
except:
|
except FileNotFoundError:
|
||||||
interface = get_bridge_interface()
|
interface = get_bridge_interface()
|
||||||
leases = {str(interface.ip): 'host'}
|
leases = {str(interface.ip): 'host'}
|
||||||
|
|
||||||
|
@ -52,18 +52,21 @@ def download_archive(archive_url, archive_path, expected_hash, observer=None):
|
|||||||
# If the signature is invalid, redownload the file
|
# If the signature is invalid, redownload the file
|
||||||
pass
|
pass
|
||||||
if do_download:
|
if do_download:
|
||||||
# Download archive via http(s) and store in temporary directory
|
do_download_archive(archive_url, archive_path, expected_hash, observer)
|
||||||
with open(archive_path, 'wb') as f, requests.Session() as session:
|
|
||||||
resource = session.get(archive_url, stream=True)
|
def do_download_archive(archive_url, archive_path, expected_hash, observer=None):
|
||||||
resource.raise_for_status()
|
# Download archive via http(s) and store in temporary directory
|
||||||
if observer:
|
with open(archive_path, 'wb') as f, requests.Session() as session:
|
||||||
for chunk in resource.iter_content(chunk_size=64*1024):
|
resource = session.get(archive_url, stream=True)
|
||||||
if chunk:
|
resource.raise_for_status()
|
||||||
observer.units_done += f.write(chunk)
|
if observer:
|
||||||
else:
|
for chunk in resource.iter_content(chunk_size=64*1024):
|
||||||
for chunk in resource.iter_content(chunk_size=64*1024):
|
if chunk:
|
||||||
if chunk:
|
observer.units_done += f.write(chunk)
|
||||||
f.write(chunk)
|
else:
|
||||||
|
for chunk in resource.iter_content(chunk_size=64*1024):
|
||||||
|
if chunk:
|
||||||
|
f.write(chunk)
|
||||||
|
|
||||||
def unpack_archive(archive_path, destination, expected_hash, observer):
|
def unpack_archive(archive_path, destination, expected_hash, observer):
|
||||||
with open(archive_path, 'rb') as f:
|
with open(archive_path, 'rb') as f:
|
||||||
|
Loading…
Reference in New Issue
Block a user