Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c707a4
commit 404c243
Showing
4 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Custom for Visual Studio | ||
*.cs diff=csharp | ||
|
||
# Standard to msysgit | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# file_watcher | ||
-sudo pip install watchdog | ||
|
||
-python watch /home/pi/pimame/roms | ||
|
||
program will watch roms folder. When a new file is created or deleted, | ||
the program will add that folder to the scrape list. If the scrape list | ||
contains changes, then it will run the scraper automatically every 60 | ||
seconds. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import sys | ||
import time | ||
import os | ||
import logging | ||
import sqlite3 | ||
from watchdog.observers import Observer | ||
#from watchdog.events import LoggingEventHandler | ||
from watchdog.events import PatternMatchingEventHandler | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser(description='PiScraper') | ||
parser.add_argument("--delay", default=60, metavar="60", help="How long to wait before running scraper", type=int) | ||
parser.add_argument("--path", default='.', metavar="/path/to/watch", help="folder to monitor", type=str) | ||
|
||
args = parser.parse_args() | ||
|
||
|
||
class EventHandler(PatternMatchingEventHandler): | ||
info = [] | ||
def on_any_event(self, event): | ||
|
||
if not event.is_directory: | ||
self.conn = sqlite3.connect('/home/pi/pimame/pimame-menu/database/config.db') | ||
self.c = self.conn.cursor() | ||
if event.event_type == 'created': | ||
self.info.append(self.c.execute('SELECT id FROM menu_items WHERE rom_path LIKE "{0}%"'.format(os.path.dirname(event.src_path))).fetchone()[0]) | ||
print 'new file found:', event.src_path | ||
if event.event_type == 'deleted': | ||
self.info.append(self.c.execute('SELECT id FROM menu_items WHERE rom_path LIKE "{0}%"'.format(os.path.dirname(event.src_path))).fetchone()[0]) | ||
print 'file deleted:', event.src_path | ||
else: print | ||
|
||
if __name__ == "__main__": | ||
path = args.path | ||
event_handler = EventHandler(ignore_patterns=['*.jpg', '*.png', '*.gif', '*.gitkeep'], case_sensitive=False) | ||
observer = Observer() | ||
observer.schedule(event_handler, path, recursive=True) | ||
observer.start() | ||
try: | ||
while True: | ||
time.sleep(args.delay) | ||
if event_handler.info: os.system('python /home/pi/pimame/pimame-menu/scraper/scrape_script.py --platform {0}'.format(str(set(event_handler.info))[5:-2].replace(' ',''))) | ||
event_handler.info = [] | ||
except KeyboardInterrupt: | ||
observer.stop() | ||
observer.join() | ||
|
Submodule pimame-menu
updated
from 9ae1e0 to df65e9