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

Commit

Permalink
related #8 - update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymoulin committed May 23, 2018
1 parent f171b89 commit 27674e1
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 34 deletions.
27 changes: 14 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,20 @@ It will *NOT* upload already existing files, *ONLY* new files while the daemon i

.. code::
usage: google-music-upload [-h] [--directory DIRECTORY] [--oauth OAUTH] [-r]
[--uploader_id UPLOADER_ID]
optional arguments:
-h, --help show this help message and exit
--directory DIRECTORY, -d DIRECTORY
Music Folder to upload from (default: .)
--oauth OAUTH, -a OAUTH
Path to oauth file (default: ~/oauth)
-r, --remove Remove files if present (default: False)
--uploader_id UPLOADER_ID, -u UPLOADER_ID
Uploader identification (should be an uppercase MAC
address) (default: <current eth0 MAC address>)
usage: google-music-uploader [-h] [--directory DIRECTORY] [--oauth OAUTH] [-r]
[--uploader_id UPLOADER_ID] [-o]
optional arguments:
-h, --help show this help message and exit
--directory DIRECTORY, -d DIRECTORY
Music Folder to upload from (default: .)
--oauth OAUTH, -a OAUTH
Path to oauth file (default: ~/oauth)
-r, --remove Remove files if present (default: False)
--uploader_id UPLOADER_ID, -u UPLOADER_ID
Uploader identification (should be an uppercase MAC
address) (default: <current eth0 MAC address>)
-o, --oneshot Upload folder and exit (default: False)
Downloader
~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion auth/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.0.1'
__version__ = '1.1.0'

setup(
name='google_music_manager_auth',
Expand Down
2 changes: 1 addition & 1 deletion downloader/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.0.1'
__version__ = '1.1.0'

setup(
name='google_music_manager_downloader',
Expand Down
3 changes: 2 additions & 1 deletion uploader/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ It will *NOT* upload already existing files, *ONLY* new files while the daemon i
.. code::
usage: google-music-uploader [-h] [--directory DIRECTORY] [--oauth OAUTH] [-r]
[--uploader_id UPLOADER_ID]
[--uploader_id UPLOADER_ID] [-o]
optional arguments:
-h, --help show this help message and exit
Expand All @@ -81,6 +81,7 @@ It will *NOT* upload already existing files, *ONLY* new files while the daemon i
--uploader_id UPLOADER_ID, -u UPLOADER_ID
Uploader identification (should be an uppercase MAC
address) (default: <current eth0 MAC address>)
-o, --oneshot Upload folder and exit (default: False)
=====
About
Expand Down
38 changes: 21 additions & 17 deletions uploader/google_music_manager_uploader/uploader_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
__DEFAULT_IFACE__ = netifaces.gateways()['default'][netifaces.AF_INET][1]
__DEFAULT_MAC__ = netifaces.ifaddresses(__DEFAULT_IFACE__)[netifaces.AF_LINK][0]['addr'].upper()


class MusicToUpload(FileSystemEventHandler):
def on_created(self, event):
self.logger.info("Detected new files!")
Expand All @@ -30,7 +31,8 @@ def on_created(self, event):
os.remove(event.src_path)


def upload(directory='.', oauth=os.environ['HOME'] + '/oauth', remove=False, uploader_id=__DEFAULT_MAC__, oneshot=False):
def upload(directory='.', oauth=os.environ['HOME'] + '/oauth', remove=False, uploader_id=__DEFAULT_MAC__,
oneshot=False):
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger.info("Init Daemon - Press Ctrl+C to quit")
Expand All @@ -47,27 +49,29 @@ def upload(directory='.', oauth=os.environ['HOME'] + '/oauth', remove=False, upl
if remove and (uploaded or matched):
os.remove(file_path)

if not oneshot:
event_handler = MusicToUpload()
event_handler.api = api
event_handler.path = directory
event_handler.willDelete = remove
event_handler.logger = logger
observer = Observer()
observer.schedule(event_handler, directory, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
if oneshot:
sys.exit(0)
event_handler = MusicToUpload()
event_handler.api = api
event_handler.path = directory
event_handler.willDelete = remove
event_handler.logger = logger
observer = Observer()
observer.schedule(event_handler, directory, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()


def main():
parser = argparse.ArgumentParser()
parser.add_argument("--directory", '-d', default='.', help="Music Folder to upload from (default: .)")
parser.add_argument("--oauth", '-a', default=os.environ['HOME'] + '/oauth', help="Path to oauth file (default: ~/oauth)")
parser.add_argument("--oauth", '-a', default=os.environ['HOME'] + '/oauth',
help="Path to oauth file (default: ~/oauth)")
parser.add_argument("-r", "--remove", action='store_true', help="Remove files if present (default: False)")
parser.add_argument("--uploader_id", '-u',
default=__DEFAULT_MAC__,
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.0.1'
__version__ = '1.1.0'

setup(
name='google_music_manager_uploader',
Expand Down

0 comments on commit 27674e1

Please sign in to comment.