Commit 26858401 by Czémán Arnold

Merge branch 'fix-flake8-warnings' into 'master'

Fix flake8 warnings

See merge request !7
parents d2fa1c61 09457c96
......@@ -61,10 +61,11 @@ def main():
else:
win32serviceutil.HandleCommandLine(AppServerSvc)
if __name__ == '__main__':
try:
main()
except (SystemExit, KeyboardInterrupt):
raise
except:
except Exception:
logger.exception("Exception:")
......@@ -6,14 +6,15 @@ import platform
import subprocess
import sys
system = platform.system()
if system == "Linux" or system == "FreeBSD":
try:
chdir(sys.path[0])
subprocess.call(('pip', 'install', '-r', 'requirements.txt'))
except:
pass # hope it works
system = platform.system() # noqa
if system == "Linux" or system == "FreeBSD": # noqa
try: # noqa
chdir(sys.path[0]) # noqa
subprocess.call(('pip', 'install', '-r', 'requirements.txt')) # noqa
except Exception: # noqa
pass # hope it works # noqa
from twisted.internet import reactor, defer
......@@ -35,6 +36,7 @@ Context = get_context()
logging.basicConfig()
logger = logging.getLogger()
level = environ.get('LOGLEVEL', 'INFO')
logger.setLevel(level)
......@@ -65,7 +67,7 @@ class SerialLineReceiver(SerialLineReceiverBase):
logger.debug("Sending tick")
try:
self.send_status()
except:
except Exception:
logger.exception("Twisted hide exception")
def __init__(self):
......@@ -136,7 +138,7 @@ class SerialLineReceiver(SerialLineReceiverBase):
if argspec.keywords:
args.append("**" + argspec.keywords)
return "%s(%s)" % (fun.__name__, ",".join(args))
except:
except Exception:
return "<%s>" % type(fun).__name__
def handle_command(self, command, args):
......@@ -159,7 +161,7 @@ def main():
try:
from notify import register_publisher
register_publisher(reactor)
except:
except Exception:
logger.exception("Could not register notify publisher")
logger.debug("Starting reactor.")
reactor.run()
......
......@@ -8,7 +8,9 @@ from shutil import rmtree, move
import subprocess
import sys
working_directory = sys.path[0]
working_directory = sys.path[0] # noqa
import logging
import fileinput
......@@ -26,6 +28,7 @@ from context import BaseContext
from twisted.internet import reactor
logger = logging.getLogger()
SSH_DIR = expanduser('~cloud/.ssh')
......@@ -96,7 +99,7 @@ class Context(BaseContext):
Context._linux_set_time(float(time))
try:
subprocess.call(['/etc/init.d/ntp', 'restart'])
except:
except Exception:
pass
@staticmethod
......@@ -142,7 +145,7 @@ class Context(BaseContext):
for line in f.readlines():
try:
retval.append(PubKey.from_str(line))
except:
except Exception:
logger.exception(u'Invalid ssh key: ')
except IOError:
pass
......@@ -170,7 +173,7 @@ class Context(BaseContext):
p = PubKey.from_str(key)
if p not in new_keys:
new_keys.append(p)
except:
except Exception:
logger.exception(u'Invalid ssh key: ')
Context._save_keys(new_keys)
......@@ -184,7 +187,7 @@ class Context(BaseContext):
new_keys.remove(p)
except ValueError:
pass
except:
except Exception:
logger.exception(u'Invalid ssh key: ')
Context._save_keys(new_keys)
......
from base64 import decodestring
from struct import unpack
import binascii
import unittest
class InvalidKeyType(Exception):
......@@ -56,8 +57,7 @@ class PubKey(object):
return u'<PubKey: %s>' % unicode(self)
import unittest
# Unit tests
class SshTestCase(unittest.TestCase):
def setUp(self):
......@@ -102,5 +102,6 @@ class SshTestCase(unittest.TestCase):
s.add(self.p3)
self.assertEqual(len(s), 2)
if __name__ == '__main__':
unittest.main()
......@@ -120,7 +120,7 @@ def notify(url):
logger.debug("wall sent, trying to start browser")
p = multiprocessing.Process(target=open_in_browser, args=(url, ))
p.start()
except:
except Exception:
logger.exception("Couldn't notify about %s" % url)
......@@ -152,7 +152,7 @@ def mount_smb(url):
stderr=subprocess.PIPE, stdout=subprocess.PIPE,
stdin=subprocess.PIPE)
logger.info('mount_smb(): %s', p.communicate())
except:
except Exception:
logger.exception('Unhandled exception: ')
......@@ -191,10 +191,11 @@ def search_display():
if "DISPLAY" in envs and ":" in envs["DISPLAY"]:
p = os.stat(os.path.join("/proc", pid))
return envs["DISPLAY"], p.st_uid, p.st_gid
except:
except Exception:
continue
return None
if win:
from twisted.internet import protocol
from twisted.protocols import basic
......@@ -256,5 +257,7 @@ def main():
args = parse_arguments()
notify(args.url)
if __name__ == '__main__':
main()
......@@ -80,10 +80,11 @@ def main():
else:
win32serviceutil.HandleCommandLine(AppServerSvc)
if __name__ == '__main__':
try:
main()
except (SystemExit, KeyboardInterrupt):
raise
except:
except Exception:
logger.exception("Exception:")
#!/usr/bin/env python
# -*- coding: utf-8 -*-
working_directory = r"C:\circle"
working_directory = r"C:\circle" # noqa
from os.path import join
......
......@@ -29,7 +29,7 @@ def check_output2(cmd, shell=False):
stdout, stderr = p.communicate()
logger.info('%s: %s, %s', cmd, stdout, stderr)
return stdout
except:
except Exception:
logger.exception(
'Unhandled exception in %s: ', cmd)
......
......@@ -78,7 +78,7 @@ class SerialPort(abstract.FileDescriptor):
self.hComPort,
self._overlappedRead,
0)
except:
except Exception:
import time
time.sleep(10)
n = 0
......
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 sign in to comment