Skip to content

Commit

Permalink
Fix flake8 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sphuber committed Dec 10, 2019
1 parent 409dd3e commit b987b5c
Show file tree
Hide file tree
Showing 36 changed files with 43 additions and 14 deletions.
2 changes: 1 addition & 1 deletion circus/circusctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def prettify(jsonobj, prettify=True):
try:
lexer = get_lexer_for_mimetype("application/json")
return pygments.highlight(json_str, lexer, TerminalFormatter())
except:
except: # noqa: E722
pass

return json_str
Expand Down
1 change: 1 addition & 0 deletions circus/commands/restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def watcher_iter_func(reverse=True):
else:
return arbiter_function()


match_options = ('match', 'match', 'glob',
"Watcher name matching method (simple, glob or regex)")

Expand Down
2 changes: 1 addition & 1 deletion circus/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def dispatch(self, job, future=None):
except OSError as e:
return self.send_error(mid, cid, msg, str(e), cast=cast,
errno=errors.OS_ERROR)
except:
except: # noqa: E722
exctype, value = sys.exc_info()[:2]
tb = traceback.format_exc()
reason = "command %r: %s" % (msg, value)
Expand Down
2 changes: 1 addition & 1 deletion circus/pidfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def unlink(self):

if pid1 == self.pid:
os.unlink(self.fname)
except:
except: # noqa: E722
pass

def validate(self):
Expand Down
8 changes: 4 additions & 4 deletions circus/stream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

from circus.util import resolve_name
from circus.stream.file_stream import FileStream
from circus.stream.file_stream import WatchedFileStream # flake8: noqa
from circus.stream.file_stream import TimedRotatingFileStream # flake8: noqa
from circus.stream.redirector import Redirector
from circus.stream.file_stream import WatchedFileStream # noqa: F401
from circus.stream.file_stream import TimedRotatingFileStream # noqa: F401
from circus.stream.redirector import Redirector # noqa: F401
from circus.py3compat import s


Expand Down Expand Up @@ -125,7 +125,7 @@ def get_stream(conf, reload=False):
# we can have 'stream' or 'class' or 'filename'
if 'class' in conf:
class_name = conf.pop('class')
if not "." in class_name:
if "." not in class_name:
cls = globals()[class_name]
inst = cls(**conf)
else:
Expand Down
2 changes: 1 addition & 1 deletion circus/tests/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ def resolve_name(name):
sys.exit(callback(test_file))
else:
sys.exit(callback())
except:
except: # noqa: E722
sys.exit(1)
3 changes: 2 additions & 1 deletion circus/tests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import multiprocessing
import socket
import sysconfig
DEBUG = sysconfig.get_config_var('Py_DEBUG') == 1

try:
from unittest import skip, skipIf, TestCase, TestSuite, findTestCases
Expand All @@ -31,6 +30,8 @@
from circus.util import IS_WINDOWS
from circus.watcher import Watcher

DEBUG = sysconfig.get_config_var('Py_DEBUG') == 1

ioloop.install()
if 'ASYNC_TEST_TIMEOUT' not in os.environ:
os.environ['ASYNC_TEST_TIMEOUT'] = '30'
Expand Down
1 change: 1 addition & 0 deletions circus/tests/test_arbiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,4 +709,5 @@ def test_circushttpd(self):
finally:
yield arbiter.stop()


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_circusctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,5 @@ def test_cli_help(self):
self.assertEqual(prompt[3], "Documented commands (type help <topic>):")
yield self.stop_arbiter()


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_circusd.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@ def _check_pid(cls):
main()
self.assertFalse(os.path.exists(pid_file))


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_command_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ def test_list_error(self):
cmd = List()
self.assertTrue("error" in cmd.console_msg({'foo': 'bar'}))


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_command_quit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ def test_quit(self):
cmd.execute(arbiter, props)
self.assertEqual(len(arbiter.watchers), 0)


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_command_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ def test_set_args(self):
watcher = arbiter.watchers[0]
self.assertEqual(watcher.options['args'], '--arg1 1 --arg2 2')


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_command_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def assert_read(channel, *values):

yield self.stop_arbiter()


test_suite = EasyTestSuite(__name__)

if __name__ == '__main__':
Expand Down
1 change: 1 addition & 0 deletions circus/tests/test_command_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ def test_execute(self):
props = {'name': 'meh', 'process': 'meh'}
self.assertRaises(MessageError, cmd.execute, arbiter, props)


test_suite = EasyTestSuite(__name__)
2 changes: 1 addition & 1 deletion circus/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def test_empty_include(self, mock_logger_warn):
"""https://github.com/circus-tent/circus/pull/473"""
try:
get_config(_CONF['empty_include'])
except:
except: # noqa: E722
self.fail('Non-existent includes should not raise')
self.assertTrue(mock_logger_warn.called)

Expand Down
1 change: 1 addition & 0 deletions circus/tests/test_convert_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ def test_hooks(self):
self.assertRaises(ArgumentError, convert_option, 'hooks',
'before_start:one:two')


test_suite = EasyTestSuite(__name__)
2 changes: 2 additions & 0 deletions circus/tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def run_circusd(options=(), config=(), log_capture_path="log.txt",
# use (lock).
pass


EXAMPLE_YAML = """\
version: 1
disable_existing_loggers: false
Expand Down Expand Up @@ -262,4 +263,5 @@ def test_loggerconfig_ini_opt(self):
additional_files={"logging.ini": logging_dictconfig_to_ini(config)}
)


test_suite = EasyTestSuite(__name__)
2 changes: 1 addition & 1 deletion circus/tests/test_papa_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def run_process(testfile, *args, **kw):
with open(testfile, 'a+') as f:
f.write('START')
time.sleep(1.)
except:
except: # noqa: E722
return 1


Expand Down
1 change: 1 addition & 0 deletions circus/tests/test_pidfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,5 @@ def test_pidfile_data(self):
except Exception as e:
self.fail(str(e))


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_plugin_command_reloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ def test_handle_recv_implemented(self):
plugin = self.make_plugin(CommandReloader, active=True)
plugin.handle_recv('whatever')


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_plugin_flapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ def test_minus_one_max_retry_triggers_restart(self, timer_mock, cast_mock):
cast_mock.assert_called_with("stop", name="test")
self.assertTrue(timer_mock.called)


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_plugin_resource_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,5 @@ def test_resource_watcher_min_cpu(self):
'_resource_watcher.test.under_cpu')
yield self.stop_arbiter()


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_plugin_watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ def test_watchdog_discovery_not_found(self):
self.assertEqual(len(pid_status), 0, pid_status)
yield self.stop_arbiter()


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_reloadconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,5 @@ def test_reload_ignorearbiterwatchers(self):
yield a.reload_from_config(_CONF['reload_statsd'])
self.assertEqual(statsd, a.get_watcher('circusd-stats'))


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ def test_dummy(self):
self.assertTrue(res)
yield self.stop_arbiter()


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_sighandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ def test_handler(self):
res = yield async_poll_for(self.test_file, 'QUIT')
self.assertTrue(res)


test_suite = EasyTestSuite(__name__)
3 changes: 2 additions & 1 deletion circus/tests/test_stats_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def run_process(*args, **kw):
os.getpid(), i))
sys.stderr.flush()
time.sleep(.25)
except:
except: # noqa: E722
return 1


Expand Down Expand Up @@ -89,4 +89,5 @@ def test_handler(self):
watcher)
yield self.stop_arbiter()


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_stats_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,5 @@ def test_socketstats(self):
self.assertTrue(stat['fd'] in self.fds)
self.assertTrue(stat['reads'] > 1)


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_stats_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ def test_publish_silent_zmq_errors_when_socket_closed(self):
stat = {'subtopic': 1, 'foo': 'bar'}
publisher.publish('foobar', stat)


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_stats_streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,5 @@ def test_remove_pid(self):
streamer.remove_pid('foobar', 1235)
self.assertTrue(streamer._callbacks['foobar'].stop.called)


test_suite = EasyTestSuite(__name__)
2 changes: 1 addition & 1 deletion circus/tests/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def run_process(testfile, *args, **kw):
with open(testfile, 'a+') as f:
f.write('START')
time.sleep(1.)
except:
except: # noqa: E722
return 1


Expand Down
1 change: 1 addition & 0 deletions circus/tests/test_umask.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def test_set_by_arbiter(self):
mode = oct(os.stat(self.test_file).st_mode)[-3:]
self.assertEqual(mode, '777')


test_suite = EasyTestSuite(__name__)

if __name__ == '__main__':
Expand Down
1 change: 1 addition & 0 deletions circus/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,5 @@ def _stat(path):
finally:
util.os.stat = _old_os_stat


test_suite = EasyTestSuite(__name__)
1 change: 1 addition & 0 deletions circus/tests/test_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,4 +671,5 @@ def test_stopping_a_watcher_doesnt_spawn(self):
# And be sure we don't spawn new processes in the meantime.
self.assertFalse(watcher.spawn_processes.called)


test_suite = EasyTestSuite(__name__)
3 changes: 2 additions & 1 deletion circus/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ def get_info(process=None, interval=0, with_childs=False):

return info


TRUTHY_STRINGS = ('yes', 'true', 'on', '1')
FALSY_STRINGS = ('no', 'false', 'off', '0')

Expand Down Expand Up @@ -618,7 +619,7 @@ def resolve_name(import_name, silent=False, reload=False):
raise_with_tb(ImportStringError(import_name, e))


_SECTION_NAME = '\w\.\-'
_SECTION_NAME = r'\w\.\-'
_PATTERN1 = r'\$\(%%s\.([%s]+)\)' % _SECTION_NAME
_PATTERN2 = r'\(\(%%s\.([%s]+)\)\)' % _SECTION_NAME
_CIRCUS_VAR = re.compile(_PATTERN1 % 'circus' + '|' +
Expand Down

0 comments on commit b987b5c

Please sign in to comment.