<commit_before>#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import pynotify
import sys
import argparse
import time

def parse_arguements():
    """
    parse the given arguements.
    """
    parser = argparse.ArgumentParser(description="""Shows notification via libnotify in the given periods. Will repead until finished.""")
    parser.add_argument('workingtime', 
        nargs=1,
        type=int,
        help="time to focus on work in minutes.")
    parser.add_argument('freetime', 
        nargs=1, 
        type=int,
        help="Time to prokrastinate in minutes")
    return parser.parse_args()

def countdown(seconds=60):
    headline = "Freetime will end"
    text = "Freetime will end in %s seconds"
    n = None
    for i in xrange(seconds):
        if n is None:
            n = pynotify.Notification(headline, text % (seconds -i))
        else:
            n.update(headline, text % (seconds -i))
        n.show()
        time.sleep(1)

def loop(args):
    n = pynotify.Notification("Worktime!", "In %s minutes begins your next freetime." % args.workingtime) 
    n.show()
    while True:
        time.sleep(args.workingtime*60)
        n = pynotify.Notification("Freetime!", "Freetime begins. You have %s minutes left" % args.freetime)
        n.show()
        time.sleep((args.freetime-1)*60)
        countdown()
        n = pynotify.Notification("Worktime!", "Freetime ends. In %s minutes begins your next freetime." % args.workingtime) 
        n.show()

def main():
    if not pynotify.init("Basics"):
        return
    args = parse_arguements()
    args.workingtime = args.workingtime[0]
    args.freetime = args.freetime[0]

    loop(args)

if __name__ == "__main__":
    main()<commit_msg>Some bugfixes. Get still the 'glib.GError: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name :1.201 was not provided by any .service files ' error after 25 Minutes of work time on Ubuntu 12.04<commit_after>#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import pynotify
import sys
import argparse
import time
import datetime

def parse_arguements():
    """
    parse the given arguements.
    """
    parser = argparse.ArgumentParser(description="""Shows notification via libnotify in the given periods. Will repead until finished.""")
    parser.add_argument('workingtime', 
        nargs=1,
        type=int,
        help="time to focus on work in minutes.")
    parser.add_argument('freetime', 
        nargs=1, 
        type=int,
        help="Time to prokrastinate in minutes")
    return parser.parse_args()

def countdown(seconds=60):
    headline = "Freetime will end"
    text = "Freetime will end in %s seconds"
    n = None
    for i in xrange(seconds):
        if n is None:
            n = send_notification(headline, text % (seconds -i))
        else:
            n.update(headline, text % (seconds -i))
            n.show()
        time.sleep(1)

def send_notification(header, text):
    """
        sends a notification and return the object for later use (updates etc)
    """
    if not pynotify.init("Basics"):
        return None
    n = pynotify.Notification(header, text) 
    n.show()
    print datetime.datetime.now().isoformat(), header, text
    return n

def _get_time_in(minutes, seperator=":"):
    """
        return the clocktime in the given minutes from now
    """
    now = datetime.datetime.now()
    delta = datetime.timedelta(minutes=minutes)
    end = now + delta
    return seperator.join(map(lambda x: str(x).zfill(2), [end.hour, end.minute]))

def loop(args):

    send_notification("Worktime!", "At %s in %s minutes begins your next freetime." % (_get_time_in(args.workingtime),args.workingtime)) 
    while True:
        time.sleep(args.workingtime*60)
        send_notification("Freetime!", "Freetime begins. You have %s minutes left" % args.freetime)
        time.sleep((args.freetime-1)*60)
        countdown()
        send_notification("Worktime!", "At %s in %s minutes begins your next freetime." % (_get_time_in(args.workingtime),args.workingtime)) 

def main():
    if not pynotify.init("Basics"):
        return
    args = parse_arguements()
    args.workingtime = args.workingtime[0]
    args.freetime = args.freetime[0]

    loop(args)

if __name__ == "__main__":
    main()
{'fraction_non_alphanumeric': 0.11903648269410665, 'fraction_numerical': 0.00912067352666043, 'mean_word_length': 2.895264116575592, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7340600', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1352, 'n_words': 370}