Beispiel #1
0
def configure_quit(signal=None):
    global default_power_settings, logger
    logger.info(
        "On exit: deactivate screensaver and set default power settings")

    write_dconf_settings(default_power_settings, logger, logaserror=False)
    execute(['xset', '-dpms'], logger)
def poke_screen(signal=None):
    global logger
    logger.info("Simulate user activity")
    poke = get_screensaver_method('SimulateUserActivity')
    poke(
        reply_handler=replying,
        error_handler=replying)
    execute(['xset','dpms','force','on'], logger)
def activate_and_poke(signal=None, mp=None):
    global logger
    poke_screen()
#    activate_screensaver()

    standby_time = inactivity
    suspend_time = inactivity + 5
    off_time = inactivity + 10
    execute(["xset", "dpms", str(standby_time), str(suspend_time), str(off_time)], logger)
    logger.info("Activated screensaver")
def get_events_from_file_ical(ical_file, limit=0, logger=None):
    ical_data = open(ical_file).read()
    events = get_events_from_string_ical(ical_data, limit, logger)

    if events != None:
        return events

    else:
        timestamp = datetime.now().replace(microsecond=0).isoformat()
        logger and logger.info(("Renaming errored calendar from  calendar.ical to calendar.ical.old.{}, a new calendar.ical file will be created in the next long heartbeat").format(timestamp))
        execute(["mv" , ical_file, ("{}.old.{}").format(ical_file, timestamp)], logger)
        return list()
Beispiel #5
0
def activate_and_poke(signal=None, mp=None):
    global logger
    poke_screen()
    #    activate_screensaver()

    standby_time = inactivity
    suspend_time = inactivity + 5
    off_time = inactivity + 10
    execute(
        ["xset", "dpms",
         str(standby_time),
         str(suspend_time),
         str(off_time)], logger)
    logger.info("Activated screensaver")
def start_galicaster():

    global galicaster
    global root, predicate

    import gi
    gi.require_version('Atspi', '2.0')
    gi.require_version('Wnck', '3.0')
    from dogtail.tree import root, predicate

    pid = is_running('run_galicaster')
    if pid:
        execute(['kill',str(pid)])
    run('python run_galicaster.py')
    galicaster = root.application('run_galicaster.py')
Beispiel #7
0
def get_events_from_file_ical(ical_file, limit=0, logger=None):
    ical_data = open(ical_file).read()
    events = get_events_from_string_ical(ical_data, limit, logger)

    if events != None:
        return events

    else:
        timestamp = datetime.now().replace(microsecond=0).isoformat()
        logger and logger.info((
            "Renaming errored calendar from  calendar.ical to calendar.ical.old.{}, a new calendar.ical file will be created in the next long heartbeat"
        ).format(timestamp))
        execute(["mv", ical_file, ("{}.old.{}").format(ical_file, timestamp)],
                logger)
        return list()
Beispiel #8
0
def start_galicaster():

    global galicaster
    global root, predicate

    import gi
    gi.require_version('Atspi', '2.0')
    gi.require_version('Wnck', '3.0')
    from dogtail.tree import root, predicate

    pid = is_running('run_galicaster')
    if pid:
        execute(['kill', str(pid)])
    run('python run_galicaster.py')
    galicaster = root.application('run_galicaster.py')
Beispiel #9
0
    def test_execute_empty_command(self):
        out = systemcalls.execute()
        self.assertEqual(out, False)

        out = systemcalls.execute([])
        self.assertEqual(out, False)

        out = systemcalls.execute(['inexistentcommand', 'params'])
        self.assertEqual(out, False)

        testfile = tempfile.NamedTemporaryFile()
        out = systemcalls.execute(['touch', testfile.name])
        self.assertEqual(out, True)
        self.assertTrue(path.exists(testfile.name))

        mtime = path.getmtime(testfile.name)
        last_modified_date = datetime.fromtimestamp(mtime)
        now = datetime.now()

        self.assertTrue(last_modified_date + timedelta(seconds=1) > now)
        self.assertTrue(last_modified_date - timedelta(seconds=1) < now)
def activate_screensaver(signal=None, mp=None):
    global inactivity, logger, power_settings
    logger.info("Activated screensaver: set power settings and activate power saving mode for {} s".format(inactivity))

    standby_time = inactivity
    suspend_time = inactivity + 5
    off_time = inactivity + 10

    write_dconf_settings(power_settings, logger, logaserror=False)
    execute(["xset", "s", "off"], logger)
    execute(["xset", "+dpms"], logger)
    execute(["xset", "dpms", str(standby_time), str(suspend_time), str(off_time)], logger)
    os.system("dconf write /org/gnome/desktop/session/idle-delay 'uint32 0'")
Beispiel #11
0
def activate_screensaver(signal=None, mp=None):
    global inactivity, logger, power_settings
    logger.info(
        "Activated screensaver: set power settings and activate power saving mode for {} s"
        .format(inactivity))

    standby_time = inactivity
    suspend_time = inactivity + 5
    off_time = inactivity + 10

    write_dconf_settings(power_settings, logger, logaserror=False)
    execute(["xset", "s", "off"], logger)
    execute(["xset", "+dpms"], logger)
    execute(
        ["xset", "dpms",
         str(standby_time),
         str(suspend_time),
         str(off_time)], logger)
    os.system("dconf write /org/gnome/desktop/session/idle-delay 'uint32 0'")
Beispiel #12
0
def deactivate_screensaver(signal=None):
    global logger
    execute(['xset', 'dpms', '0', '0', '0'], logger)
def deactivate_screensaver(signal=None):
    global logger
    execute(['xset', 'dpms', '0', '0', '0'], logger)
Beispiel #14
0
def poke_screen(signal=None):
    global logger
    logger.info("Simulate user activity")
    poke = get_screensaver_method('SimulateUserActivity')
    poke(reply_handler=replying, error_handler=replying)
    execute(['xset', 'dpms', 'force', 'on'], logger)
def configure_quit(signal=None):
    global default_power_settings, logger
    logger.info("On exit: deactivate screensaver and set default power settings")

    write_dconf_settings(default_power_settings, logger, logaserror=False)
    execute(['xset', '-dpms'], logger)
Beispiel #16
0
def unconfigure_keyboard(dispatcher=None):
    write_dconf_settings({'/org/onboard/use-system-defaults': 'true'}, logger)
    pid = is_running('onboard')
    if pid:
        execute(['kill', str(pid)])
def unconfigure_keyboard(dispatcher=None):
    write_dconf_settings({'/org/onboard/use-system-defaults':'true'},logger)
    pid = is_running('onboard')
    if pid:
        execute(['kill', str(pid)])
Beispiel #18
0
 def test_execute_error(self):
     out = systemcalls.execute(['ls', 'non existent'])
     self.assertEqual(out, False)
def open_folder(path):
    logger.info("Opening folder {0}".format(path))
    return_code = execute(['xdg-open', '{}'.format(path)], logger)
    return return_code