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

Commit

Permalink
Recursive file iterator for file uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymoulin committed May 23, 2017
1 parent 9345e01 commit 3ec483e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions uploader-daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import time
import logging
import os
import glob
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from gmusicapi import Musicmanager
Expand All @@ -15,8 +16,8 @@ class MusicToUpload(FileSystemEventHandler):
def on_created(self, event):
self.logger.info("Detected " + event.src_path)
if os.path.isdir(event.src_path):
for f in os.listdir(event.src_path):
file_path = os.path.join(event.src_path, f)
files = [file for file in glob.glob(path + '/**/*', recursive=True)]
for file_path in files:
if os.path.isfile(file_path):
self.logger.info("Uploading : " + file_path)
self.api.upload(file_path, True)
Expand Down Expand Up @@ -44,8 +45,8 @@ def on_created(self, event):
event_handler.logger = logger
if api.login(oauth):
if willDelete:
for f in os.listdir(path):
file_path = os.path.join(path, f)
files = [file for file in glob.glob(path + '/**/*', recursive=True)]
for file_path in files:
if os.path.isfile(file_path):
logger.info("Uploading : " + file_path)
api.upload(file_path, True)
Expand Down

0 comments on commit 3ec483e

Please sign in to comment.