Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions mig/server/genjobscriptpython.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
Expand Down Expand Up @@ -31,13 +31,13 @@
from __future__ import print_function
from __future__ import absolute_import

from builtins import object

Check failure on line 34 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused import 'object' (90% confidence)
import os

from mig.shared.defaults import job_output_dir


class GenJobScriptPython(object):

Check failure on line 40 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused class 'GenJobScriptPython' (60% confidence)
"""Python job script generator"""

def __init__(
Expand All @@ -54,10 +54,10 @@
self.resource_conf = resource_config
self.exe = exe_unit
self.https_sid_url_arg = https_sid_url
self.filename_without_extension = filename_without_ext

Check failure on line 57 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused attribute 'filename_without_extension' (60% confidence)
self.localjobname = localjobname

exe_dir = ''

Check failure on line 60 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused variable 'exe_dir' (60% confidence)
exe_list = self.resource_conf.get('EXECONFIG', [])
for exe_conf in exe_list:
if exe_conf['name'] == self.exe:
Expand Down Expand Up @@ -108,12 +108,12 @@
file_extension + "'"
return cmd

def comment(self, string):

Check failure on line 111 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused method 'comment' (60% confidence)
"""Insert comment"""

return '""" ' + string + ' """ \n'

def script_init(self):

Check failure on line 116 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused method 'script_init' (60% confidence)
"""initialize script"""

return '''#!/usr/bin/python
Expand All @@ -138,7 +138,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Check warning on line 141 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
#
# -- END_HEADER ---
#
Expand All @@ -149,13 +149,13 @@
from os.path import join, getsize
'''

def print_start(self, name='job'):

Check failure on line 152 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused method 'print_start' (60% confidence)
"""print 'starting new job'"""
"""Print 'starting new job'"""

return "print 'Starting new %s with JOB_ID: %s'\n" % \
return "print('Starting new %s with JOB_ID: %s')\n" % \
(name, self.job_dict['JOB_ID'])

def create_files(self, files):

Check failure on line 158 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

unused method 'create_files' (60% confidence)
"""Create supplied files"""

cmd = ''
Expand Down Expand Up @@ -214,7 +214,7 @@
mig_server_filename = "%s" % parts[0]
try:
resource_filename = "%s" % parts[1]
except:

Check warning on line 217 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

do not use bare 'except'
resource_filename = mig_server_filename

# Source may be external in which case implicit destination needs
Expand Down Expand Up @@ -268,7 +268,7 @@
mig_server_filename = "%s" % parts[0]
try:
resource_filename = "%s" % parts[1]
except:

Check warning on line 271 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

do not use bare 'except'
resource_filename = mig_server_filename

# Source may be external in which case implicit destination needs
Expand Down Expand Up @@ -296,14 +296,14 @@
cmd = ''
cmd += 'dst = sys.argv[-1]\n'
cmd += 'for name in sys.argv[1:-1]:\n'
cmd += ' name_on_resource = os.path.join(dst, os.path.basename(name))\n'

Check warning on line 299 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
# NOTE: for security we do not invoke shell here
cmd += ' subprocess.call("%s")\n' % \
self.__curl_cmd_get('name', 'name_on_resource')
return cmd

def generate_input_filelist(self, result='generate_input_filelist'):
"""Generate filelist (user/system) of which files

Check warning on line 306 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

trailing whitespace
should be transfered from FE to EXE before job execution."""

cmd = '# Create files used by master_node_script ' + \
Expand All @@ -318,7 +318,7 @@
mig_server_filename = "%s" % parts[0]
try:
resource_filename = "%s" % parts[1]
except:

Check warning on line 321 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

do not use bare 'except'
resource_filename = mig_server_filename

# Source may be external in which case implicit destination needs
Expand Down Expand Up @@ -349,7 +349,7 @@
mig_server_filename = "%s" % parts[0]
try:
resource_filename = "%s" % parts[1]
except:

Check warning on line 352 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

do not use bare 'except'
resource_filename = mig_server_filename

# Source may be external in which case implicit destination needs
Expand Down Expand Up @@ -447,11 +447,11 @@
return cmd

def generate_mountsshprivatekey_file(self,
result='generate_mountsshprivatekey_file'):

Check warning on line 450 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (84 > 80 characters)
"""Generate file containing mount ssh private key."""

cmd = '# Create file used containing mount private key.\n'
cmd += 'mountprivkey_fd = open("%s.mount.key", "w")\n' % self.localjobname

Check warning on line 454 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)
cmd += 'mountprivKey_fd.write("%s")\n' % \
self.job_dict['MOUNTSSHPRIVATEKEY']
cmd += 'mountprivkey_fd.close()\n'
Expand Down Expand Up @@ -584,7 +584,7 @@

for exe in self.job_dict['EXECUTE']:
exe = exe.replace('"', '\\"')
cmd += 'print "' + pretext + exe + '"\n'
cmd += 'print("' + pretext + exe + '")\n'

cmd += 'if "' + exe + '".find(" >> ") != -1:\n'
cmd += ' filehandle = subprocess.Popen("' + exe + ' 2>> ' + \
Expand All @@ -599,7 +599,7 @@
cmd += 'else:\n'
cmd += ' status = "%s" % status\n'
cmd += 'status_handle.write("' + exe + ' %s\\n" % status)\n'
cmd += 'print "' + posttext + '%s" % status\n'
cmd += 'print("' + posttext + '%s" % status)\n'

cmd += 'status_handle.close()\n'

Expand Down Expand Up @@ -634,7 +634,7 @@
resource_filename = "%s" % parts[0]
try:
mig_server_filename = "%s" % parts[1]
except:

Check warning on line 637 in mig/server/genjobscriptpython.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

do not use bare 'except'
mig_server_filename = resource_filename

# External destinations will always be explicit so no
Expand Down Expand Up @@ -711,10 +711,10 @@
successcode='0',
msg='ERROR: unexpected exit code!',
):
"""Print msg unless last command exitted with successcode"""
"""Print msg unless last command exited with successcode"""

cmd = 'if ' + result + ' != ' + successcode + ':\n'
cmd += '\tprint "WARNING: ' + msg + "\(\" + " + result + " + \"\)\"\n"
cmd += '\tprint("WARNING: ' + msg + ' (" + ' + result + ' + ")")\n'
cmd += '\n'
return cmd

Expand Down Expand Up @@ -751,8 +751,8 @@
reflected in frontend_script!
"""

return 'print "' + name + ' script end reached ' + \
self.job_dict['JOB_ID'] + '" \nsys.exit(' + exitcode + ')\n' + \
return 'print("' + name + ' script end reached ' + \
self.job_dict['JOB_ID'] + '")\nsys.exit(' + exitcode + ')\n' + \
'### END OF SCRIPT ###\n'

def clean_up(self):
Expand Down
2 changes: 1 addition & 1 deletion mig/server/genjobscriptsh.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
Expand Down Expand Up @@ -1106,7 +1106,7 @@
"""Print msg unless result contains success code"""

cmd = 'if [ $' + result + ' -ne ' + successcode + ' ]; then\n'
cmd += '\techo "WARNING: ' + msg + "\($" + result + "\)\"\n"
cmd += '\techo "WARNING: ' + msg + '($' + result + ')"\n'
cmd += 'fi\n'
return cmd

Expand Down
Loading