Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
fixes observer when not in oneshot + fixes makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymoulin committed Jul 5, 2018
1 parent bcfbb12 commit 8f39a67
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
10 changes: 3 additions & 7 deletions auth/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
.PHONY: install clean check

test:
make install
test: install
twine upload -r testpypi dist/*
publish:
make install
publish: install
twine upload dist/*
install:
make clean
make check
install: clean check
sudo python3 setup.py sdist
check:
python3 setup.py check --restructuredtext
Expand Down
10 changes: 3 additions & 7 deletions downloader/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
.PHONY: install clean check

test:
make install
test: install
twine upload -r testpypi dist/*
publish:
make install
publish: install
twine upload dist/*
install:
make clean
make check
install: clean check
sudo python3 setup.py sdist
check:
python3 setup.py check --restructuredtext
Expand Down
24 changes: 13 additions & 11 deletions uploader/google_music_manager_uploader/uploader_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def upload_file(api, file_path, logger, oauth=os.environ['HOME'] + '/oauth', upl
uploaded, matched, not_uploaded = api.upload(file_path, True)
if remove and (uploaded or matched):
os.remove(file_path)
retry = 0
retry = 0
except CallFailure as e:
error_message = str(e)
if "401" in error_message:
Expand All @@ -59,21 +59,23 @@ def upload(directory='.', oauth=os.environ['HOME'] + '/oauth', remove=False, upl
if not api.login(oauth, uploader_id):
print("Error with oauth credentials")
sys.exit(1)
observer = None
if not oneshot:
event_handler = MusicToUpload()
event_handler.api = api
event_handler.oauth = oauth
event_handler.uploader_id = uploader_id
event_handler.path = directory
event_handler.remove = remove
event_handler.logger = logger
observer = Observer()
observer.schedule(event_handler, directory, recursive=True)
observer.start()
files = [file for file in glob.glob(glob.escape(directory) + '/**/*', recursive=True)]
for file_path in files:
upload_file(api, file_path, logger, oauth, uploader_id, remove)
if oneshot:
sys.exit(0)
event_handler = MusicToUpload()
event_handler.api = api
event_handler.oauth = oauth
event_handler.uploader_id = uploader_id
event_handler.path = directory
event_handler.remove = remove
event_handler.logger = logger
observer = Observer()
observer.schedule(event_handler, directory, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
Expand Down
2 changes: 1 addition & 1 deletion uploader/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from setuptools import setup, find_packages

__version__ = '1.2.0'
__version__ = '1.2.1'

setup(
name='google_music_manager_uploader',
Expand Down

0 comments on commit 8f39a67

Please sign in to comment.