New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM-7185: Python 3 #2
Conversation
autopep8 {{package_dir}} --in-place --recursive --ignore E26,E133,E226,E228,N802,N803 --max-line-length 110
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. There are some issues that need resolving.
if os.path.exists(filename) == False: | ||
print "file %s not found" % filename | ||
|
||
if os.path.exists(filename) is False: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that os.path.exists()
returns a boolean I think it would be clearer as:
if not os.path.exists(filename):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
UNKNOWN_PLATFORM_EXIT_CODE = 10 | ||
MISSING_PBS_CONFIG_EXIT_CODE = 20 | ||
# UNKNOWN_PLATFORM_EXIT_CODE = 10 | ||
# MISSING_PBS_CONFIG_EXIT_CODE = 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these not being used then? Are they informational?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are intended to be used at a later date when we have severity levels. I'm looking into this later this month.
@@ -55,7 +56,7 @@ def main(): | |||
sys.stdin.close() | |||
sys.stdout.close() | |||
sys.stderr.close() | |||
if creator.isVerbose == False: | |||
if creator.isVerbose is False: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not creator.isVerbose:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
try: | ||
from shlex import split as cmd_split | ||
except ImportError: | ||
from pipes import split as cmd_split |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this because shlex
has the split
function in python 2 and 3 and pipes
never seems to have it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to look at this again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what happened there. Must have been a copy buffer paste. Thanks for catching that.
# If there is no space, the dataid is something simple like a skytile id | ||
newData=myData | ||
# If there is no space, the dataid is something simple like a skytile id | ||
newData = myData | ||
visit = str(int(count / 100)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
visit = str(count // 100)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -38,7 +42,7 @@ def nextSeq(self): | |||
@return a sequence number | |||
""" | |||
seq = 0 | |||
if os.path.exists(self.fileName) == False: | |||
if os.path.exists(self.fileName) is False: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not os.path.exists():
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -37,16 +46,26 @@ def test1(self): | |||
filename = os.path.join("tests", "testfiles", "test.diamond.dag") | |||
|
|||
stdout = self.executeCommand("%s %s A1 %s" % (exe, execPath, filename)) | |||
self.assertTrue(stdout == "run=1033 filter=r camcol=2 field=229\n") | |||
stdout = bytes(stdout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make more sense for executeCommand
to use decode()
to decode the output from the command and convert it to a real string. Then drop all this bytes
stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
absolutely. don't know what I was thinking.
filename = os.path.join("/tmp",username+"_"+str(os.getpid())+".seq") | ||
if os.path.exists(filename) == True: | ||
filename = os.path.join("/tmp", username+"_"+str(os.getpid())+".seq") | ||
if os.path.exists(filename) is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the is True
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced that test
def test1(self): | ||
username = pwd.getpwuid(os.geteuid()).pw_name | ||
filename = os.path.join("/tmp",username+"_"+str(os.getpid())+".seq") | ||
if os.path.exists(filename) == True: | ||
filename = os.path.join("/tmp", username+"_"+str(os.getpid())+".seq") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use lsst.utils.tests.getTempFilePath()
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely so. I'll check. This code pre-dates that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. Replaced that code to use getTempFilePath().
def test1(self): | ||
pairs = {} | ||
pairs["TEST1"] = "Hello" | ||
pairs["TEST2"] = "Goodbye" | ||
infile = os.path.join("tests", "testfiles", "templateWriter.template") | ||
compare = os.path.join("tests", "testfiles", "templateWriter.txt") | ||
username = pwd.getpwuid(os.geteuid()).pw_name | ||
outfile = os.path.join("/tmp",username+"_"+str(os.getpid())+"_template.txt") | ||
outfile = os.path.join("/tmp", username+"_"+str(os.getpid())+"_template.txt") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lsst.utils.tests.getTempFilePath()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. Replaced that code to use getTempFilePath()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About the commit messages, our Developer Guide asks us to write commit messages in the imperative tense.
|
||
def test1(self): | ||
username = pwd.getpwuid(os.geteuid()).pw_name | ||
filename = os.path.join("/tmp", username+"_"+str(os.getpid())+".seq") | ||
if os.path.exists(filename) == True: | ||
if os.path.exists(filename) is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is Ture
not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -222,7 +221,7 @@ def createConfiguration(self, input): | |||
@return the newly created Orca configuration file | |||
""" | |||
resolvedInputName = envString.resolve(input) | |||
if self.opts.verbose == True: | |||
if self.opts.verbose is True: | |||
print("creating configuration using ", resolvedInputName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is True
not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
self.outputFileName = os.path.join(configDir, "%s_config.py" % (self.runid)) | ||
if self.opts.verbose == True: | ||
self.outputFileName = os.path.join(configDir, "%s.config" % (self.runid)) | ||
if self.opts.verbose is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is True
not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -234,10 +233,10 @@ def createConfiguration(self, input): | |||
substitutes["CTRL_EXECUTE_SETUP_PACKAGES"] = self.getSetupPackages() | |||
|
|||
configDir = os.path.join(substitutes["LOCAL_SCRATCH"], "configs") | |||
if os.path.exists(configDir) == False: | |||
if os.path.exists(configDir) is False: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not os.path.exists(configDir):
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -38,7 +38,7 @@ | |||
dagNode = sys.argv[1] | |||
filename = sys.argv[2] | |||
|
|||
if os.path.exists(filename) == False: | |||
if os.path.exists(filename) is False: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not os.path.exists(filename)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -23,30 +23,40 @@ | |||
import unittest | |||
import os.path | |||
from lsst.ctrl.execute.allocationConfig import AllocationConfig | |||
import lsst.utils.tests | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume these changes in tests/
are not done by flake8; the commit message "flake8 code cleanup" is then confusing..
@@ -61,5 +61,5 @@ class CondorInfoConfig(pexConfig.Config): | |||
filename = envString.resolve(filename) | |||
config.load(filename) | |||
|
|||
for i in config.platform.keys(): | |||
for i in list(config.platform.keys()): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as the other list()
+keys()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Removed redundant references using list(keys())
No description provided.