Fix linting issues

This commit is contained in:
rhpvorderman
2017-06-12 17:35:34 +02:00
parent 01cffa6151
commit 64f5e2e2fa
3 changed files with 18 additions and 16 deletions
+2 -2
View File
@@ -1771,12 +1771,12 @@ class JobWrapper( object, HasResourceParameters ):
if self.__user_system_pwent is None:
job = self.get_job()
if self.app.config.real_system_username == 'user_email':
if self.app.config.real_system_username == 'user_email':
try:
self.__user_system_pwent = pwd.getpwnam( job.user.email.split('@')[0] )
except KeyError:
pass
elif self.app.config.real_system_username == 'username':
elif self.app.config.real_system_username == 'username':
try:
self.__user_system_pwent = pwd.getpwnam( job.user.username )
except KeyError:
+3 -3
View File
@@ -283,15 +283,15 @@ def create_paramfile( trans, uploaded_datasets ):
def _chown( path ):
try:
# get username from email/username
pwent = None
pwent = None
if trans.app.config.real_system_username == 'user_email':
if trans.app.config.real_system_username == 'user_email':
try:
pwent = pwd.getpwnam( trans.user.email.split('@')[0] )
except KeyError:
pass
elif trans.app.config.real_system_username == 'username':
elif trans.app.config.real_system_username == 'username':
try:
pwent = pwd.getpwnam( trans.user.username )
except KeyError:
+13 -11
View File
@@ -7,9 +7,10 @@ import sys
# if set to None every file can be modified by the script.
# this can increase security in particular if write access to this
# script is removed by the admin.
#
#
# ALLOWED_PATHS = [ "job_working_directory", "new_file_path" ]
ALLOWED_PATHS = None
ALLOWED_PATHS = None
def validate_paramters():
if len(sys.argv) < 4:
@@ -17,7 +18,7 @@ def validate_paramters():
exit(1)
path = os.path.abspath( sys.argv[1] )
if ALLOWED_PATHS == None:
if ALLOWED_PATHS is None:
allowed = True
else:
allowed = False
@@ -26,7 +27,7 @@ def validate_paramters():
allowed = True
break
if not allowed:
sys.stderr.write( "owner and group modifications in %s are not allowed\n" %path )
sys.stderr.write( "owner and group modifications in %s are not allowed\n" % path )
sys.exit( 1 )
galaxy_user_name = sys.argv[2]
@@ -39,20 +40,21 @@ def main():
path, galaxy_user_name, gid = validate_paramters()
cmd = [ 'chown', '-Rh', galaxy_user_name, path ]
p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p = os.subprocess.Popen(cmd, shell=False, stdout=os.subprocess.PIPE, stderr=os.subprocess.PIPE)
(stdoutdata, stderrdata) = p.communicate()
exitcode = p.returncode
if exitcode != 0:
sys.stderr.write("external_chown_script: could not chown\ncmd was %s\n"% " ".join(cmd))
raise exit(1)
sys.stderr.write("external_chown_script: could not chown\ncmd was %s\n" % " ".join(cmd))
raise exit(1)
cmd = [ 'chgrp', '-Rh', gid, path ]
p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p = os.subprocess.Popen(cmd, shell=False, stdout=os.subprocess.PIPE, stderr=os.subprocess.PIPE)
(stdoutdata, stderrdata) = p.communicate()
exitcode = p.returncode
if exitcode != 0:
sys.stderr.write("external_chown_script: could not chgrp\ncmd was %s\n"% " ".join(cmd))
raise exit(1)
sys.stderr.write("external_chown_script: could not chgrp\ncmd was % s\n" % " ".join(cmd))
raise exit(1)
if __name__ == "__main__":
main()