Skip to content

Commit

Permalink
Merge pull request #2495 from matthewrmshin/codacy
Browse files Browse the repository at this point in the history
Fix selected issues reported by Codacy
  • Loading branch information
oliver-sanders authored Dec 8, 2017
2 parents 038e334 + 4aa5e2e commit 721a22e
Show file tree
Hide file tree
Showing 121 changed files with 567 additions and 500 deletions.
2 changes: 1 addition & 1 deletion bin/cylc-broadcast
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute(force_required=True):
if remrun():
sys.exit(0)

import re
Expand Down
6 changes: 3 additions & 3 deletions bin/cylc-cat-log
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ window, or 'View in Editor' opens a temporary copy of it in your editor."""

import sys
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

import os
Expand Down Expand Up @@ -331,7 +331,7 @@ def main():
'%s:%s' % (user_at_host, filename), viewfile]
else:
cp = ['cp', filename, viewfile]
proc = Popen(cp, stderr=PIPE, stdout=PIPE)
proc = Popen(cp, stdin=open(os.devnull), stderr=PIPE, stdout=PIPE)
err = proc.communicate()[1]
ret_code = proc.wait()
if ret_code:
Expand Down Expand Up @@ -365,7 +365,7 @@ def main():
sys.stderr.write(
" ".join(quote(item) for item in command) + "\n")
stderr = None
proc = Popen(command, stderr=stderr)
proc = Popen(command, stdin=open(os.devnull), stderr=stderr)
err = proc.communicate()[1]
ret_code = proc.wait()
if ret_code == 0:
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-cat-state
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This command is deprecated; use "cylc ls-checkpoints" instead."""

import sys
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

import os
Expand Down
11 changes: 4 additions & 7 deletions bin/cylc-check-versions
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ User -v/--verbose to see the command invoked to determine the remote version
site dependent -- see cylc global config documentation."""

import sys
import subprocess
from subprocess import Popen, PIPE

import cylc.flags
from cylc.remote import remrun
from cylc.option_parsers import CylcOptionParser as COP
from cylc.version import CYLC_VERSION
from cylc.config import SuiteConfig, SuiteConfigError
Expand Down Expand Up @@ -99,11 +98,9 @@ def main():
user_at_host = host
if verbose:
print "%s: %s" % (user_at_host, ' '.join(argv))
p = subprocess.Popen(
argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
res = p.wait()
if res == 0:
proc = Popen(argv, stdin=open(os.devnull), stdout=PIPE, stderr=PIPE)
out, err = proc.communicate()
if proc.wait() == 0:
if verbose:
print " %s" % out
contacted += 1
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-checkpoint
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import sys
if "--use-ssh" in sys.argv[1:]:
sys.argv.remove("--use-ssh")
from cylc.remote import remrun
if remrun().execute(force_required=True):
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-diff
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ suite definition directory are not currently differenced."""

import sys
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
6 changes: 3 additions & 3 deletions bin/cylc-documentation
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ import sys
for arg in sys.argv[1:]:
if arg.startswith('--host=') or arg.startswith('--user='):
from cylc.remote import remrun
if remrun().execute(force_required=True, forward_x11=True):
if remrun(forward_x11=True):
sys.exit(0)

import os
import re
import subprocess
from subprocess import call
from optparse import OptionParser

import cylc.flags
Expand Down Expand Up @@ -168,7 +168,7 @@ def main():
sys.exit(0)

try:
retcode = subprocess.call(command_list)
retcode = call(command_list, stdin=open(os.devnull))
except OSError as exc:
print >> sys.stderr, 'ERROR, failed to execute: %s' % command
if cylc.flags.debug:
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-dump
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
8 changes: 4 additions & 4 deletions bin/cylc-edit
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ See also 'cylc [prep] view'."""

import sys
from cylc.remote import remrun
if remrun().execute(forward_x11=True):
if remrun(forward_x11=True):
sys.exit(0)

import os
import re
import datetime
import subprocess
from subprocess import call
from shutil import copy

import cylc.flags
Expand Down Expand Up @@ -124,7 +124,7 @@ def main():
command_list.append(suiterc)
command = ' '.join(command_list)
# THIS BLOCKS UNTIL THE COMMAND COMPLETES
retcode = subprocess.call(command_list)
retcode = call(command_list, stdin=open(os.devnull))
if retcode != 0:
# the command returned non-zero exist status
print >> sys.stderr, command, 'failed:', retcode
Expand Down Expand Up @@ -172,7 +172,7 @@ def main():
command_list.append(suiterc)
command = ' '.join(command_list)
# THIS BLOCKS UNTIL THE COMMAND COMPLETES
retcode = subprocess.call(command_list)
retcode = call(command_list, stdin=open(os.devnull))
if retcode != 0:
# the command returned non-zero exist status
print >> sys.stderr, command, 'failed:', retcode
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-get-directory
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ from cylc.suite_srv_files_mgr import SuiteSrvFilesManager
import cylc.flags

from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)


Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-get-suite-config
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $ cylc get-suite-config --item=[runtime][modelX] SUITE

import sys
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

import re
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-get-suite-contact
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Print contact information of running suite REG."""

import sys
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

from cylc.option_parsers import CylcOptionParser as COP
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-get-suite-version
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-graph
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ from cylc.suite_srv_files_mgr import SuiteSrvFilesManager
from cylc.task_id import TaskID
from cylc.templatevars import load_template_vars

if remrun().execute(forward_x11=True):
if remrun(forward_x11=True):
sys.exit(0)

from cylc.option_parsers import CylcOptionParser as COP
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-gscan
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import sys
if "--use-ssh" in sys.argv[1:]:
sys.argv.remove("--use-ssh")
from cylc.remote import remrun
if remrun().execute(forward_x11=True):
if remrun(forward_x11=True):
sys.exit(0)

import gtk
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-gui
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute(forward_x11=True):
if remrun(forward_x11=True):
sys.exit(0)

import os
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-hold
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute(force_required=True):
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-insert
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute(force_required=True):
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-jobs-kill
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def main():
BatchSysManager().jobs_kill(args[0], args[1:])


if __name__ == "__main__" and not remrun().execute():
if __name__ == "__main__" and not remrun():
from cylc.option_parsers import CylcOptionParser as COP
from cylc.batch_sys_manager import BatchSysManager
main()
2 changes: 1 addition & 1 deletion bin/cylc-jobs-poll
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def main():
BatchSysManager().jobs_poll(args[0], args[1:])


if __name__ == "__main__" and not remrun().execute():
if __name__ == "__main__" and not remrun():
from cylc.option_parsers import CylcOptionParser as COP
from cylc.batch_sys_manager import BatchSysManager
main()
2 changes: 1 addition & 1 deletion bin/cylc-jobs-submit
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main():
args[0], args[1:], remote_mode=opts.remote_mode)


if __name__ == "__main__" and not remrun().execute():
if __name__ == "__main__" and not remrun():
from cylc.option_parsers import CylcOptionParser as COP
from cylc.batch_sys_manager import BatchSysManager
main()
2 changes: 1 addition & 1 deletion bin/cylc-kill
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute(force_required=True):
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-list
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ viewer tool. To visualize the full multiple inheritance hierarchy use:
import os
import sys
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

from cylc.config import SuiteConfig
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-ls-checkpoints
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ parameters, task pool and broadcast states in the suite runtime database.

import sys
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

import os
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-nudge
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-ping
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-poll
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute(force_required=True):
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-print
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ to prevent this ('foo$' matches only literal 'foo')."""

import sys
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

import os
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-register
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The suite can subsequently be started and targeted by cylc commands using

import sys
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

from cylc.option_parsers import CylcOptionParser as COP
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-release
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute(force_required=True):
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-reload
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-remove
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute(force_required=True):
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-report-timings
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ the database query to obtain the timing information may take some time.

import sys
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

import cStringIO as StringIO
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-reset
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import sys
if '--use-ssh' in sys.argv[1:]:
sys.argv.remove('--use-ssh')
from cylc.remote import remrun
if remrun().execute(force_required=True):
if remrun():
sys.exit(0)

import cylc.flags
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-restart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import sys
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)

from cylc.scheduler_cli import main
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-run
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import sys
from cylc.remote import remrun
if remrun().execute():
if remrun():
sys.exit(0)


Expand Down
Loading

0 comments on commit 721a22e

Please sign in to comment.