def debug(self, string): """ Print a given string if DEBUG is toggled on, either in this script, or globally. @param string: The given string. """ if self.get_debug(): outputs.print_debug(string)
def schedule(self): event_file = open(self.file, 'w') event_file.write(self.command + "\n") event_file.write(self.operand) event_file.close() if conf.DEBUG: outputs.print_debug("Scheduled " + self.command + " at " + str(self.date))
def debug(string): """ Prints a given debug string if debug is toggled on. @param string: The given debug string. """ if conf.DEBUG: outputs.print_debug(string)
def debug(string): """ Shows the given string as debug info if debug is toggled on. @param string: The given string. """ if conf.DEBUG: outputs.print_debug(string)
def __init__(self, date, command, operand): if not isinstance(date, datetime.datetime): outputs.print_error("class mismatch: date argument is not a datetime object.") exit(1) self.date = date self.command = command self.operand = operand self.file = os.path.join(conf.SCHEDULING_DIR, str(self.date)) if conf.DEBUG: outputs.print_debug("Constructed event " + str(self))
def get_event_from_file(path): date = datetime.datetime.strptime(os.path.basename(path), '%Y-%m-%d %H:%M:%S') event_file = open(os.path.join(conf.SCHEDULING_DIR, path)) lines = event_file.readlines() cmd = lines[0].strip() operand = lines[1].strip() e = Event(date, cmd, operand) if conf.DEBUG: outputs.print_debug("Got event from file " + path + " : " + str(e)) return e
def go_to_sleep_mode(seconds): if seconds == 0: if not conf.DEBUG: cmd = "pm-suspend" system.call_silently(cmd, sudo=True) else: outputs.print_debug("going to sleep indefinitely") else: cmd = "sudo rtcwake --mode mem " if conf.DEBUG: cmd += "--dry-run " cmd += "--seconds " + str(seconds) if not conf.DEBUG: system.call_silently(cmd, sudo=True) else: system.call(cmd, sudo=True)
def decide_meaning(self, string): """ Decides to which script the given string belongs. @param string: The given string. @return: Nothing. """ meaning_found = None for name in self.scripts_dict: matched, operand = self.means(string, name) if matched: meaning_found = name break if conf.DEBUG: if meaning_found: outputs.print_debug("decided " + string + " to mean " + meaning_found + ".") else: outputs.print_debug("No meaning found.") return meaning_found, operand
def decide_meaning(string): """ Decides which meaning the given string has. @param string: A given string @return: A string, representing the meaning of the given string. """ meaning_found = None for meaning in MEANINGS_DICT: if means(string, meaning): meaning_found = meaning break if conf.DEBUG: if meaning_found: outputs.print_debug("decided " + string + " to mean " + meaning_found + ".") else: outputs.print_debug("No meaning found.") return meaning_found
def __init__(self, path): foldernames = path.split('/') self.title = foldernames[-1] self.artist = foldernames[-3] self.album = foldernames[-2] if conf.DEBUG: outputs.print_debug("Constructed song:") outputs.print_debug("Title: " + self.title) outputs.print_debug("Artist " + self.artist) outputs.print_debug("Album: " + self.album) self.path = path
def debug(string): if _get_config_module().DEBUG or config.get_global_debug(): outputs.print_debug(string)
def debug(string): if conf.DEBUG: outputs.print_debug(string)
def open(url): if conf.DEBUG: outputs.print_debug("Opening URL in browser: " + url) system.call_silently("xdg-open \"" + url + "\"", sync=False)
def debug(string): if conf.DEBUG: print_debug(string)
def delete(self): if os.path.exists(self.file): os.remove(self.file) if conf.DEBUG: outputs.print_debug("Removed event file " + self.file)
def make_if_nonexistent(path): if not os.path.exists(path): os.mkdir(path) if conf.DEBUG: outputs.print_debug("Created " + path + " directory.")