Beispiel #1
0
def tmux_string():
	try:
		with open(data_file_path(), "r") as f:
			s = f.read().split()
			(status, imp) = ("ON"==s[0]), datetime(*map(int, s[1:]))
	except IOError:
		logging.info("The data_file %s does was not found" % data_file_path())
		return

	now = datetime.now()
	x = imp-now
	# Only print if the session is recent
	logging.info("Status, x: %d %s" % (status, str(x)))
	if status or x>timedelta(0, -60*60):
		print tmux_format(status, x)
	else:
		logging.info("The session is old - not printing")
Beispiel #2
0
def tomato_string():
    try:
        with open(data_file_path(), "r") as f:
            s = f.read().split()
            (status, imp) = ("ON" == s[0]), datetime(*map(int, s[1:]))
    except IOError:
        info("The data_file %s was not found" % data_file_path())
        return ""

    now = datetime.now()
    x = imp - now
    # Only print if the session is recent
    info("Status, x: %d %s" % (status, str(x)))
    if status or x > timedelta(0, -60 * 60):
        return tmux_format(status, x)
    else:
        info("The session is old - not printing")
        return ""
Beispiel #3
0
def write_data(session):
	if not session.toggles:
		return
	# Write the important time and status to file
	# This is the information which is needed by the tmux_string function
	with open(data_file_path(), "w") as f:
		# This is a string "ON" or otherwise, and a space separated list of
		# integers representing the date: year, month, day, hour, minute,
		# second
		status = session.status()
		imp = session.important_time()
		if status: st="ON"
		else: st="OFF"
		f.write("%s" % st + imp.strftime(" %Y %m %d %H %M %S") + "\n")
Beispiel #4
0
def write_data(session):
    if not session.toggles:
        return
    # Write the important time and status to file
    # This is the information which is needed by the tmux_string function
    with open(data_file_path(), "w") as f:
        # This is a string "ON" or otherwise, and a space separated list of
        # integers representing the date: year, month, day, hour, minute,
        # second
        status = session.status()
        imp = session.important_time()
        if status: st = "ON"
        else: st = "OFF"
        f.write("%s" % st + imp.strftime(" %Y %m %d %H %M %S") + "\n")
Beispiel #5
0
def quiet():
	os.remove(data_file_path())
Beispiel #6
0
def quiet():
	os.remove(data_file_path())
Beispiel #7
0
                       nargs=1,
                       action="store",
                       type=str,
                       metavar="path",
                       help="Monitor a folder for activity")
    args = parser.parse_args()
    if args.verbose:
        logging.basicConfig(format="%(asctime)s %(levelname)s : %(message)s",
                            level=logging.INFO,
                            datefmt="%-H:%M:%S")

    if args.tmux:
        tmux_string()

    elif args.toggle:
        toggle()

    elif args.quiet:
        os.remove(data_file_path())

    elif args.report:
        day, week = unshelve()
        plot(day, week)

    elif args.monitor is not None:
        set_log_folder(args.monitor[0])

    else:
        print "Doing nothing..."
        print "Run './main.py --help' for help with options"