Skip to content

Various improvements #1

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

jdm
Copy link

@jdm jdm commented Jan 5, 2017

These are changes that I've made that allowed me to run this for several days uninterrupted using the no-api mode. I want to split them up into logical commits before merging, but I figured I should store them somewhere besides the machine under my desk.

@jdm jdm changed the title Local changes [do not merge] Various improvements Jan 24, 2017
@jdm
Copy link
Author

jdm commented Jan 24, 2017

I've split this up into logical separate changes and I'd love feedback!

@wafflespeanut
Copy link
Member

Meh, I should've assigned this to myself. Somehow, I didn't get notified by your commits split-up. I'll look into it today.

@wafflespeanut wafflespeanut self-assigned this Feb 1, 2017
Copy link
Member

@wafflespeanut wafflespeanut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the changes, except a few comments...

suite = config['suite']
else:
subdir = None
suite = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These subdir and suite declarations could be removed. After making this check, we should have subdir=config.get('subdir'), suite=config.get('suite') in the constructor below.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice to not include the keys in the config file when no specific suite or subdirectory is desired, and it's not clear to me if there's an API that returns default values for nonexistent keys.

Copy link
Member

@wafflespeanut wafflespeanut Feb 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, so, I was thinking of something like,

if 'subdir' in config and 'suite' not in config:
    sys.exit(1)

# defaults to None
watcher = IntermittentWatcher(..., suite=config.get('suite'), subdir=config.get('subdir'))

if is_dummy:
print '\033[1m\033[93mRunning in dummy mode: API will not be used!\033[0m'
if os.path.exists(log_path):
with open(log_path, 'r') as fd:
self.results = json.load(fd)
else:
self.results = {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This should be moved to the top along with the other declarations. Let's override if the log exists already.

with open(STDOUT_LOG, 'wb') as f:
f.write(out)

if out.find(OUTPUT_HEAD) == -1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Have a out = '' and result = out.find(OUTPUT_HEAD) above please.

@@ -42,6 +53,8 @@ def execute(self, command):
sys.stdout.flush()
out += line
proc.wait()
if not suppress and proc.returncode != 0:
raise subprocess.CalledProcessError(proc.returncode, command, out)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious. What's the purpose of having a suppress here? We don't seem to use this option anywhere?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do - all of the git commands use the implicit value of suppress=False, meaning that errors encountered while running them will abort execution.

Copy link
Member

@wafflespeanut wafflespeanut Feb 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful. I didn't see that coming.

@@ -96,7 +125,7 @@ def run(self):
self.results[test]['subtest'][subtest]['data'] = result

self.log('Cleaning up recordings...')
for test, result in self.results.iteritems():
for test, result in list(self.results.iteritems()):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd gone for iteritems only for the sake of having an iterator here. Why do we need a list? If we really need it, we could just have self.results.items()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code in the for loop modifies self.results, which breaks if an iterator is in use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, self.results.items() then :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants