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

Commit

Permalink
Silencing debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
workmajj committed Aug 11, 2011
1 parent a7c09dc commit a41645e
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions slushbox/slushbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from applescripts import OPEN_SCRIPT, RELOAD_SCRIPT, IS_OPEN_SCRIPT

BROWSER = "Google Chrome"
DEBUG = False

def osascript(script):
return commands.getoutput("osascript -e '%s'" % (script))
Expand All @@ -25,26 +26,29 @@ def page_is_open(directory, window, tab):

def reload_page(page, window, tab, event):
# See fsevents for inotify names.
if event.mask & fsevents.IN_MODIFY:
print "File modified: %s" % (event.name)
elif event.mask & fsevents.IN_ATTRIB:
print "File modified: %s" % (event.name)
elif event.mask & fsevents.IN_CREATE:
print "File created: %s" % (event.name)
elif event.mask & fsevents.IN_DELETE:
print "File deleted: %s" % (event.name)
elif event.mask & fsevents.IN_MOVED_FROM:
print "File renamed: %s" % (event.name)
elif event.mask & fsevents.IN_MOVED_TO:
print "File renamed: %s" % (event.name)
if DEBUG:
if event.mask & fsevents.IN_MODIFY:
print "File modified: %s" % (event.name)
elif event.mask & fsevents.IN_ATTRIB:
print "File modified: %s" % (event.name)
elif event.mask & fsevents.IN_CREATE:
print "File created: %s" % (event.name)
elif event.mask & fsevents.IN_DELETE:
print "File deleted: %s" % (event.name)
elif event.mask & fsevents.IN_MOVED_FROM:
print "File renamed: %s" % (event.name)
elif event.mask & fsevents.IN_MOVED_TO:
print "File renamed: %s" % (event.name)

print "Using %s to reload file: %s" % (BROWSER, page)
if DEBUG:
print "Using %s to reload file: %s" % (BROWSER, page)
output = osascript(RELOAD_SCRIPT % (BROWSER, tab, window))
if re.search(r'got an error', output):
raise Exception("Window and/or tab no longer open.")

def open_page(page):
print "Using %s to open file: %s" % (BROWSER, page)
if DEBUG:
print "Using %s to open file: %s" % (BROWSER, page)
output = osascript(OPEN_SCRIPT % (BROWSER, page))
r = re.search(r'tab id (\d+) of window id (\d+)', output)
if not r:
Expand Down

0 comments on commit a41645e

Please sign in to comment.