-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Bugfix/issue 2727 #2740
Bugfix/issue 2727 #2740
Conversation
Hello @dzekem! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2020-11-18 15:57:29 UTC |
Hello, @dzekem, thank you for helping with the Mycroft project! We welcome everyone To protect yourself, the project, and users of Mycroft technologies we require Please visit https://mycroft.ai/cla to initiate this one-time signing. Thank |
Voight Kampff Integration Test Failed (Results) |
Hi Dzekem, thanks for flagging this and creating a PR to fix it! I'm wondering if it's worth us adding a small helper function to Maybe something like: import os
import tempfile
def create_temp_path(*args):
try:
path = os.path.join(tempfile.gettempdir(), *args)
except TypeError:
path = None
LOG.error('Could not create a temp path, create_temp_path() only accepts Strings')
return path This would mean we can use it across Mycroft in a more simplified fashion: from mycroft.util import create_temp_path
temp_directory = create_temp_path('mycroft')
temp_file = create_temp_path('somefile.ext') I haven't seen a CLA request come through so please let me know if you run into any problems or have questions about it. I also saw the Github weirdness on this PR, it's really easy to do and happens to all of us. I'd suggest rebasing your PR off the dev branch. There's instructions for this in our contributing guidelines but again shout out if you run into problems. For the PEP8 issues I'd suggest using an automated tool like autopep8 to check and fix these. They all seem like tiny issues, but enforcing this helps us keep the codebase smaller, cleaner and more consistent which makes it easier to read. If you aren't already feel free to join us in Mycroft Chat, the dev channel is a good place to ask questions on all of the above. Thanks |
Voight Kampff Integration Test Failed (Results) |
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.
Generally looks great, thanks for fixing these issues!
I had a couple of nit-picks to keep the coding style in line with the current file. The big issues I saw was a changed path and a small typo in a function call
mixer.setvolume(prev_vol) | ||
play_wav("/tmp/test.wav").communicate() | ||
play_wavv(os.path.join(tempfile.gettempdir(), "test.wav").communicate() |
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.
typo, should be play_wav
new_config = {'opt_in': enable} | ||
user_config = LocalConf(USER_CONFIG) | ||
new_config={'opt_in': enable} | ||
user_config=LocalConf(USER_CONFIG) |
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.
spaces around =
signs. Here and a lot of places
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.
something is confusing autopep8 in this file, it intentionally removes the white spaces here...
I've just spent far too long messing with my config but it only seems to happen for this file.
Going to resort to manually hitting the space bar 🤯
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.
and the problem was OBVIOUSLY (read - not obviously) a missing closing parentheses on line 134 🤦
also apologies to @dzekem when I peeked into this PR I thought you hadn't responded to the change requests, but I see now that you ran autopep8 on everything it was just masked by this obscure typo!
mycroft/lock/__init__.py
Outdated
@@ -98,7 +99,8 @@ class Lock: # python 3+ 'class Lock' | |||
|
|||
# | |||
# Class constants | |||
DIRECTORY = '/tmp/mycroft' | |||
DIRECTORY = os.path.join(tempfile.gettempdir(), | |||
"mycroft", "ipc") # '/tmp/mycroft' |
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.
This seems to change the directory from /tmp/mycroft
to /tmp/mycroft/ipc
mycroft/skills/skill_updater.py
Outdated
import sys | ||
from datetime import datetime | ||
from time import time | ||
|
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.
This space should remain here I think since above are builtin packages and msm is a non-system package but not included in the mycroft module
test/unittests/lock/test_lock.py
Outdated
if exists('/tmp/mycroft'): | ||
rmtree('/tmp/mycroft') | ||
if exists(os.path.join(tempfile.gettempdir(), "mycroft")): | ||
rmtree(os.path.join(tempfile.gettempdir(), "mycroft")) |
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.
use '
like the rest of the file to keep it consistent. (here and other places in this file)
@krisgesling we do have a similar function in the utils |
mycroft/util/audio_test.py
Outdated
'-f', '--filename', dest='filename', default="/tmp/test.wav", | ||
help="Filename for saved audio (Default: /tmp/test.wav)") | ||
'-f', '--filename', dest='filename', default=os.path.join(tempfile.gettempdir(), "test.wav"), | ||
help="Filename for saved audio (Default: os.path.join(tempfile.gettempdir(), "test.wav")") |
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.
here you should probably do
Saw this flagged by travis, it should probably be
help="Filename for saved audio (Default: {}".format(os.path.join(tempfile.gettempdir(), "test.wav")))
Voight Kampff Integration Test Failed (Results) |
1 similar comment
Voight Kampff Integration Test Failed (Results) |
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.
Seems to be a couple of minor issues still. But we're getting there :)
import sys | ||
import os | ||
import tempfile |
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.
imported twice now?
@@ -220,7 +223,7 @@ class EnclosureWriter(Thread): | |||
Note: A command has to end with a line break | |||
""" | |||
|
|||
def __init__(self, serial, bus, size=16): | |||
def __init__(self, serial, bus, size = 16): |
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.
In function-calls there should be no spaces around =
.
It's weird but that's the pep8 style :/
mixer.setvolume(prev_vol) | ||
play_wav("/tmp/test.wav").communicate() | ||
play_wav(os.path.join(tempfile.gettempdir(), 'test.wav').communicate() |
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 this line is missing a closing parenthesis )
Voight Kampff Integration Test Failed (Results) |
@@ -135,7 +134,7 @@ def process(self, data): | |||
time.sleep(0.5) # Prevents recording the loud button press | |||
record(os.path.join(tempfile.gettempdir(), 'test.wav'), 3.0) | |||
mixer.setvolume(prev_vol) | |||
play_wav(os.path.join(tempfile.gettempdir(), 'test.wav').communicate() | |||
play_wav(os.path.join(tempfile.gettempdir(), 'test.wav').communicate()) |
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.
Not sure about this but I think it should be
play_wav(os.path.join(tempfile.gettempdir(), 'test.wav')).communicate()
since play_wav returns a subprocess object we want to communicate with to ensure it's finished.
862cdce
to
9c2c93c
Compare
9c2c93c
to
d560fa2
Compare
Voight Kampff Integration Test Succeeded (Results) |
1 similar comment
Voight Kampff Integration Test Succeeded (Results) |
Voight Kampff Integration Test Failed (Results) |
Voight Kampff Integration Test Failed (Results) |
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.
Found two small typos in the PR.
mixer.setvolume(prev_vol) | ||
play_wav("/tmp/test.wav").communicate() | ||
play_wav(creat_temp_path('test.wav')).communicate() |
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.
should be create_temp_path
test/unittests/util/test_download.py
Outdated
from threading import Event | ||
from unittest import TestCase, mock | ||
|
||
from mycroft.util.download import (download, _running_downloads, | ||
_get_download_tmp) | ||
from mycroft.util import create_temp_path |
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.
should be from mycroft.util.file_utils import create_temp_path
Voight Kampff Integration Test Succeeded (Results) |
I've sent a CLA request and it's been days no reply yet. Also thank you for the suggestion of using a function which I have made use of where necessary in the code |
Hey sorry about that, there's still some manual steps in our CLA process and I missed the email. You should now have an email from HelloSign. Let me know if it doesn't show up or you have any questions about it :) |
Thank you I've signed and submitted it. |
Voight Kampff Integration Test Failed (Results) |
Voight Kampff Integration Test Failed (Results) |
Can't this be closed now #2892 is merged? |
Indeed - thanks :) |
No description provided.