Formatting

This commit is contained in:
James Barnsley
2020-02-03 16:48:39 +13:00
parent df18eba73c
commit b789d322b3
5 changed files with 269 additions and 127 deletions

View File

@ -1,5 +1,8 @@
from threading import Thread
import logging, os, pathlib, subprocess, json, sys
import logging
import os
import pathlib
import subprocess
# import logger
logger = logging.getLogger(__name__)
@ -14,9 +17,9 @@ class IrisSystemPermissionError(IrisSystemError):
def __init__(self, path):
message = (
"Password-less access to %s was refused. Check your /etc/sudoers file."
% path.as_uri()
)
r'''Password-less access to %s was refused.
Check your /etc/sudoers file.''' %
path.as_uri())
logger.error(message)
super().__init__(message)
@ -63,7 +66,8 @@ class IrisSystemThread(Thread):
command = self.get_command()
logger.debug("Running '%s'", os.fsdecode(b" ".join(command)))
process = subprocess.Popen(command, stdout=subprocess.PIPE, encoding="utf8")
process = subprocess.Popen(
command, stdout=subprocess.PIPE, encoding="utf8")
lines = ""
while True:
@ -73,8 +77,6 @@ class IrisSystemThread(Thread):
if line:
logger.info(line)
lines = lines + "\n" + line
# This seems to be ignored. Detected as spammy io?
# self.ioloop.add_callback(lambda: self.callback(None, None, {'output': line}))
if process.returncode == 0:
self.ioloop.add_callback(
@ -92,10 +94,14 @@ class IrisSystemThread(Thread):
##
def can_run(self, *args, **kwargs):
# Attempt an empty call to our system file
command_bytes = b" ".join(self.get_command("check", non_interactive=True))
command_bytes = b" ".join(
self.get_command(
"check", non_interactive=True))
process = subprocess.Popen(
command_bytes, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True
)
command_bytes,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
result, error = process.communicate()
exitCode = process.wait()