Пример #1
0
 def testPauseAndResumePomodoros(self):
     pomo = Pomodoro()
     # we cannot pause a Pomodoro that has not been started yet
     self.assertRaises( Exception, pomo.pause )
     pomo.start()
     time1 = pomo.getTimeLeft()
     pomo.pause()
     time.sleep(1)
     pomo.resume()
     time2 = pomo.getTimeLeft()
     self.assertTrue( time2 + timedelta(seconds=1) < time1  )
Пример #2
0
 def test_afterPomodoroIsInterrupted_itWillNoLongerCallBack(self):
     self.timeUp = False
     self.pomodoro = Pomodoro(self.whenTimeup, 0.001)
     self.pomodoro.start()
     self.pomodoro.stop()
     sleep(0.1)
     self.assertFalse(self.timeUp, "whenTimeup should not have been called")
Пример #3
0
    def __init__(self):
        """
            Initializer for the Pomodoro GUI class
        """
        super(PymodoroGUI, self).__init__()

        self.res_dir = os.path.join("../ext/")
        self.green_tomato_icon = os.path.join(self.res_dir, "greentomato.png")
        self.red_tomato_icon = os.path.join(self.res_dir, "redtomato.png")
        self.tray = QSystemTrayIcon(QIcon(self.green_tomato_icon))
        self.pom = Pomodoro()
        self.pom.ringer.connect(self.signal)
        self.init_ui()
Пример #4
0
def pomodoro_callback(bot, update, **kwargs):
    global pomodoro
    args = kwargs.get('args')
    _job_queue = kwargs.get('job_queue')

    if args[0] == 'start':
        logger.info('starting pomodoro')
        pomodoro = Pomodoro()
        _job_queue.run_repeating(pomodoro_alarm,
                                 interval=0,
                                 first=0,
                                 context=update.message.chat_id)

    if args[0] == 'stop':
        logger.info('stopping pomodoro')
        pomodoro = None
        _job_queue.enabled = False
Пример #5
0
 def start_clicked(self):
     self.start_text.set("Cancel")
     pomodoro = Pomodoro()
     stoppable = pomodoro.start(self.on_pomodoro_step, self.on_pomodoro_end)
     self.start_button.configure(command=lambda: self.cancel_clicked(stoppable))
Пример #6
0
from pomodoro import Pomodoro

pomodoro = Pomodoro()
pomodoro.start()
Пример #7
0
from pomodoro import Pomodoro

if __name__ == '__main__':
    pomodoro = Pomodoro()
    pomodoro.short_break()
Пример #8
0
def main():

    # create pomodoro & begin first task

    task_goal = input("Enter the number of tasks you want to do today: ")
    task_length_minutes = input("Enter the length of each task: ")
    short_break_length = input("Enter the length of a short break: ")
    long_break_length = input("Enter the length of a long break: ")
    pomodoro = Pomodoro(task_goal, long_break_length, short_break_length,
                        task_length_minutes)
    pomodoro.start_task()

    while True:

        # Initialize last_summary variable to 15 seconds in the past
        last_summary = pomodoro.timer_start - timedelta(seconds=15)

        # while the timer is running
        while pomodoro.get_time_remaining() > timedelta(seconds=0):

            current_time = datetime.now()

            # print a summary of the current timer every 15 seconds
            if (current_time - last_summary) > timedelta(seconds=15):
                pomodoro.print_summary()

                # update timer to track when the last summary was printed
                last_summary = current_time

        # if we are on a task, complete the task.  Otherwise, we start the task timer
        if pomodoro.timer_type == Pomodoro.TIMER_TASK:

            # complete the task
            pomodoro.complete_task()

            # check to see if need to continue to a break or stop the pomodoro
            if pomodoro.done():
                break
            if pomodoro.task_count % pomodoro.long_break_goal == 0:
                pomodoro.start_long_break()
            else:
                pomodoro.start_short_break()
        else:
            pomodoro.start_task()

    # we have met our pomodoro goal
    print("\nPomodoro Complete!")
def load_pomodoro():
    Pomodoro.show_saved_pomodoros()
    choice = input('\nPlease select a pomodoro to load: ')
    p = Pomodoro(Pomodoro.load_pomodoro(choice))
    return p
Пример #10
0
from pomodoro import Pomodoro
from breakTime import BreakTime, BreakEnum
import time

total_checkmark_to_long_break = 5

btime = BreakTime(3, 15)
pomodoro = Pomodoro(2, total_checkmark_to_long_break)


def startBreak(checkmark, cicle, breakType):
    print('\n--- Time to rest! ---\n')
    btime.run(breakType)
    pomodoro.run()


pomodoro.onFinishSection += startBreak

pomodoro.run()
Пример #11
0
 def setUp(self):
     self.pomodoro = Pomodoro(self.whenTimeup)
Пример #12
0
class TestPomodoroBehaviour(unittest.TestCase):

    def setUp(self):
        self.pomodoro = Pomodoro(self.whenTimeup)
        
    def whenTimeup(self):
        self.timeUp = True

    def test_afterCreation_pomodoroIsNotRunning(self):
        self.assertFalse(self.pomodoro.isRunning())
        
    def test_afterCreation_pomodoroIsNotInterrupted(self):
        self.assertFalse(self.pomodoro.wasInterrupted())
        
    def test_afterCreation_timeRemainingInSecondsIsEquivalentToTwentyFiveMinutes(self):
        self.assertEqual(1500, self.pomodoro.timeRemaining)
        
    def test_interruptingAPomodoroThatIsNotRunningIsANotRunningException(self):
        self.assertRaises(PomodoroNotRunning, self.pomodoro.stop)
        
    def test_startingAPomodoroThatIsAlreadyStartedIsAnAlreadyStartedException(self):
        self.pomodoro.start()
        self.assertRaises(PomodoroAlreadyStarted, self.pomodoro.start)

    def test_afterStarting_PomodoroCallsBackWhenTimesUp(self):
        self.timeUp = False
        self.pomodoro = Pomodoro(self.whenTimeup, 0.001)
        self.pomodoro.start()
        sleep(0.1)
        self.assertTrue(self.timeUp)
        
    def test_afterStarting_isRunningReturnsTrue(self):
        self.pomodoro.start()
        self.assertTrue(self.pomodoro.isRunning())
    
    def test_afterStarting_canQueryTimeRemainingWhileRunning(self):
        self.pomodoro.start()
        self.assertEqual(1500, self.pomodoro.timeRemaining)
        
    def test_afterInterrupting_wasInterruptedReturnsTrue(self):
        self.pomodoro.start()
        self.pomodoro.stop()
        self.assertTrue(self.pomodoro.wasInterrupted())
                
    def test_afterPomodoroIsInterrupted_itWillNoLongerCallBack(self):
        self.timeUp = False
        self.pomodoro = Pomodoro(self.whenTimeup, 0.001)
        self.pomodoro.start()
        self.pomodoro.stop()
        sleep(0.1)
        self.assertFalse(self.timeUp, "whenTimeup should not have been called")
    
    def test_afterInterrupting_isRunningReturnsFalse(self):
        self.pomodoro.start()
        self.pomodoro.stop()
        self.assertFalse(self.pomodoro.isRunning())
        
    def test_afterPomodoroEnds_itsNoLongerRunningNorInterrupted(self):
        self.pomodoro = Pomodoro(self.whenTimeup, 0.001)
        self.pomodoro.start()
        sleep(0.1)
        self.assertFalse(self.pomodoro.isRunning())
        self.assertFalse(self.pomodoro.wasInterrupted())
Пример #13
0
 def testStartAndRestartPomodoros(self):
     pomo = Pomodoro()
     pomo.start()
     self.assertTrue( pomo.getTimeLeft() < timedelta(minutes=25), 'A started pomodoro initiates the countdown' )
     pomo.start()
     self.assertTrue( pomo.getTimeLeft().seconds/60 == 24 )
Пример #14
0
from flask_socketio import SocketIO

# Create a webserver object called 'Shared Pomodoro' and keep track of it in the variable called server
server = Flask("Shared Pomodoro")
# Create a socketio object to handle web sockets


# Define an HTTP route / to serve the pomodoro page
@server.route('/')
# Define the function 'serve_index_page()' and connect it to the route /
def serve_index_page():
    # Return the static file 'index.html'
    return server.send_static_file('index.html')


socketio = SocketIO(server, cors_allowed_origins="*")


def handle_control_c(signal, frame):
    pomodoro.stop()
    exit()


#construct a pomodoro object
pomodoro = Pomodoro()
pomodoro.start()
signal.signal(signal.SIGINT, handle_control_c)
pomodoro.press()

# Start the webserver
socketio.run(server, host="0.0.0.0", debug=True)
Пример #15
0
from pomodoro import Pomodoro

if __name__=='__main__':
    pomodoro = Pomodoro()
    pomodoro.long_break()
Пример #16
0
class PymodoroGUI(QWidget):
    """
        GUI for Pymodoro
    """
    def __init__(self):
        """
            Initializer for the Pomodoro GUI class
        """
        super(PymodoroGUI, self).__init__()

        self.res_dir = os.path.join("../ext/")
        self.green_tomato_icon = os.path.join(self.res_dir, "greentomato.png")
        self.red_tomato_icon = os.path.join(self.res_dir, "redtomato.png")
        self.tray = QSystemTrayIcon(QIcon(self.green_tomato_icon))
        self.pom = Pomodoro()
        self.pom.ringer.connect(self.signal)
        self.init_ui()

    def signal(self, pomodori):
        """
            Callback given to the Pomodoro class.
            Called when a pomodoro is up
        """
        if pomodori % 4 == 0 and pomodori != 0:
            self.tray.showMessage("4 Pomodori has passed!",
                                   "Take a long break: 15-30min",
                                   QSystemTrayIcon.Information)
        else:
            self.tray.showMessage("Pomodoro's up!",
                                   "Take a short break: 3-5min",
                                   QSystemTrayIcon.Information)
        self.tray.setIcon(QIcon(self.green_tomato_icon))

    def init_tray(self):
        """
            Initializes the systray menu
        """
        traymenu = QMenu("Menu")
        self.tray.setContextMenu(traymenu)
        self.tray.show()
        self.tray.activated.connect(self.tray_click)
        self.tray.setToolTip("Pomodori: "+str(self.pom.pomodori))

        set_timer_tray = QLineEdit()
        set_timer_tray.setPlaceholderText("Set timer")
        set_timer_tray.textChanged.connect(lambda:
                                           self.update_timer_text(set_timer_tray.text()))
        traywidget = QWidgetAction(set_timer_tray)
        traywidget.setDefaultWidget(set_timer_tray)
        traymenu.addAction(traywidget)

        start_timer_action = QAction("&Start Timer", self)
        start_timer_action.triggered.connect(self.start_timer_click)
        traymenu.addAction(start_timer_action)

        exit_action = QAction("&Exit", self)
        exit_action.triggered.connect(QCoreApplication.instance().quit)
        traymenu.addAction(exit_action)

    def tray_click(self, activation):
        """
            Method called when clicking the tray icon
        """
        if activation == QSystemTrayIcon.Trigger:
            if self.isVisible():
                self.hide()
            else:
                self.show()
        elif activation == QSystemTrayIcon.Context:
            self._tray.show()

    def close_event(self, event):
        self._tray.showMessage("Running in system tray",
                                """The program will keep running in the system tray.\n
                                To terminate the program choose exit from the context menu""",
                                QSystemTrayIcon.Information)
        self.hide()
        event.ignore()

    def wheel_event(self, event):
        if event.delta() > 0:
            timervalue = int(self.settimertext.text())
            timervalue = timervalue + 1
            self.settimertext.setText(str(timervalue))
        else:
            timervalue = int(self.settimertext.text())
            timervalue = timervalue - 1
            self.settimertext.setText(str(timervalue))

    def init_ui(self):
        """
            Initializes the GUI
        """
        self.init_tray()
        resolution = QApplication.desktop().availableGeometry()
        width = 150
        height = 100

        # place exactly in center of screen
        self.setGeometry((resolution.width() / 2) - (width / 2),
                         (resolution.height() / 2) - (height / 2),
                         width, height)
        self.setWindowTitle("Pomodoro")
        self.setWindowIcon(QIcon(os.path.join(self.res_dir, "redtomato.png")))

        grid = QGridLayout()
        grid.setSpacing(5)
        self.settimertext = QLineEdit()
        grid.addWidget(self.settimertext, 1, 0)

        self.errortext = QLabel()
        grid.addWidget(self.errortext, 2, 0)
        self.errortext.hide()

        self.settimertext.setText(str(25))
        self.settimertext.textChanged.connect(lambda:
                                              self.update_timer_text(
                                                 self.settimertext.text()))

        self.start_timerbutton = QPushButton("start timer")
        grid.addWidget(self.start_timerbutton, 3, 0)
        self.start_timerbutton.clicked.connect(self.start_timer_click)

        self.setLayout(grid)
        self.show()

    def start_timer_click(self):
        """
            Method run when starting the pomodoro timer
        """
        self.pom.start_timer()
        self.tray.setIcon(QIcon(self.red_tomato_icon))
        self.hide()

    def update_timer_text(self, number):
        """
            Method run when setting the number of minutes in the timer
        """
        try:
            self.pom.set_timer_minutes(int(number))
            self.errortext.hide()
        except ValueError:
            self.errortext.setText("Please input a number")
            self.errortext.show()
Пример #17
0
from PySide2.QtCore import QUrl
from PySide2.QtQml import QQmlApplicationEngine
from PySide2 import QtGui
import sys
from timer import Timer
from pomodoro import Pomodoro
from history import TaskListModel

if __name__ == "__main__":
    sys.argv += ["--style", "material"]
    app = QtGui.QGuiApplication(sys.argv)
    timer = Timer()
    pomodoro = Pomodoro()
    engine = QQmlApplicationEngine()
    engine.rootContext().setContextProperty("timer", timer)
    engine.rootContext().setContextProperty("pomodoro", pomodoro)
    engine.rootContext().setContextProperty("taskListModel",
                                            TaskListModel(engine=engine))
    engine.load(QUrl("./qml/view.qml"))

    sys.exit(app.exec_())
Пример #18
0
import os

from pomodoro import Pomodoro

os.chdir("..")  # Go up one directory from working directory

# Create database if it does not exist
database_path = "data\pomodoros.db"
if not os.path.exists(database_path):
    print("Creating database ...")
    os.system("database.py")

conn = sqlite3.connect("data\pomodoros.db")
cursor = conn.cursor()

pomodoro = Pomodoro(cursor)

### Main loop
while True:
    # Show the categories available
    category_id = pomodoro.show_categories()
    project_id = pomodoro.show_projects(category_id)
    pomodoro_time = input("Add the length of the pomodoro in minutes: ")

    # call for the timer
    pomodoro.timer(minutes=pomodoro_time)

    # Rest timer
    pomodoro.timer(mode="rest")

    # Ask for satisfaction
Пример #19
0
def main():
    pomodoro = Pomodoro()
    pomodoro.run()
Пример #20
0
 def test_afterStarting_PomodoroCallsBackWhenTimesUp(self):
     self.timeUp = False
     self.pomodoro = Pomodoro(self.whenTimeup, 0.001)
     self.pomodoro.start()
     sleep(0.1)
     self.assertTrue(self.timeUp)
from pomodoro import Pomodoro

if __name__ == '__main__':
    pomodoro = Pomodoro()
    pomodoro.medium_break()
Пример #22
0
 def testPomodoroNotActiveAfterItsTimePassed(self):
     pomo = Pomodoro(seconds=1)
     pomo.start()
     time.sleep(1)
     self.assertRaises( Exception, pomo.pause )
Пример #23
0
def run(new):
    while True:
        if new == False:
            p = load_pomodoro()
            new = True

        show_commands()
        choice = input('\nWhat would you like to do? ')

        if choice == 'a':
            if not p:
                p = Pomodoro()

            while True:
                task = input('\nTask: ')
                p.add_task({"task": task, "complete": False})
                response = input('\nWould you like to add another task? ')

                if response == 'n':
                    break

        elif choice == 'r':
            try:
                p.check_tasks()
                to_remove = input('\nPlease select a task to remove: ')
                p.remove_task(int(to_remove))

            except UnboundLocalError:
                print('\nYou have not loaded or created a pomodoro session, so no tasks can be deleted')
        
        elif choice == 's':
            filename = input('\nPlease enter a name for your save: ')
            p.save_tasks(filename=filename)
        
        elif choice == 'p':
            p.check_tasks()
        
        elif choice == 'b':
            # TODO: add the running of a pomodoro
            p.begin_pomodoro()

        else:
            break
Пример #24
0
 def test_afterPomodoroEnds_itsNoLongerRunningNorInterrupted(self):
     self.pomodoro = Pomodoro(self.whenTimeup, 0.001)
     self.pomodoro.start()
     sleep(0.1)
     self.assertFalse(self.pomodoro.isRunning())
     self.assertFalse(self.pomodoro.wasInterrupted())
Пример #25
0
 def testPomodoroPausesCounter(self):
     pomo = Pomodoro()
     pomo.start()
     self.assertEquals( pomo.pauses, 0 )
     pomo.pause()
     pomo.resume()
     self.assertEquals( pomo.pauses, 1 )
     i=0
     while i<10:
         pomo.pause()
         pomo.resume()
         i += 1
     self.assertEquals( pomo.pauses, 11 )