Example #1
0
    def combine_btn(self):
        combine_file = filedialog.askopenfilename()
        if (combine_file):
            write_combine = open("temp.ics", "w+")
            combine_string = "./caltool -combine %s < %s > temp.ics" % (
                combine_file, self.cur_file)
            os.system(combine_string)
            cal_combine_string = write_combine.read()
            self.result = []
            cal_status = cal.readFile("temp.ics", self.result)
            write_combine.close()
            self.saved = FALSE

            self.prop_tree.delete(*self.prop_tree.get_children())
            size = (len(self.result[1]))
            for i in range(0, size):
                self.prop_tree.insert(
                    "",
                    END,
                    text=i + 1,
                    values=(self.result[1][i][0], self.result[1][i][1],
                            self.result[1][i][2], self.result[1][i][3]))

            write_info = open("temp.txt", "w+")
            info_string = "./caltool -info < temp.ics > temp.txt"
            os.system(info_string)
            write_info.close()
            cal_info = open("temp.txt", "r")
            cal_info_string = cal_info.read()

            self.log_text.config(state=NORMAL)
            self.log_text.insert(END, cal_info_string + "\n")
            self.log_text.see(END)
            self.log_text.config(state=DISABLED)
Example #2
0
def readAndDisplayComp(fileName,fvpTree):
    newCalData = []
    status = "OK"
    status = cal.readFile(fileName,newCalData)

    if (status == "OK"):

        newCal = calFile(newCalData[0],newCalData[1],newCalData[2])

        fvpTree.clear()
        fvpTree.addCal(newCal)
    return(status)
Example #3
0
    def filter_btn(self, num, to_var, from_var):
        n1 = num.get()
        from1 = from_var.get()
        to1 = to_var.get()

        self.filter_msg.destroy()
        write_filter = open("filter.ics", "w+")
        root.title("%s*" % (self.cur_file))
        self.saved = 1

        if n1 == 1:
            if from1 == "":
                filter_string = "./caltool -filter t < %s > filter.ics" % (
                    self.cur_file)
            else:
                filter_string = "./caltool -filter t from \"%s\" to \"%s\" < %s > filter.ics" % (
                    from1, to1, self.cur_file)
        else:
            if from1 == "":
                filter_string = "./caltool -filter e < %s > filter.ics" % (
                    self.cur_file)
            else:
                filter_string = "./caltool -filter e from \"%s\" to \"%s\" < %s > filter.ics" % (
                    from1, to1, self.cur_file)

        os.system(filter_string)
        cal_filter_string = write_filter.read()
        write_filter.close()
        self.result = []
        cal_status = cal.readFile("filter.ics", self.result)

        self.prop_tree.delete(*self.prop_tree.get_children())
        size = (len(self.result[1]))
        for i in range(0, size):
            self.prop_tree.insert(
                "",
                END,
                text=i + 1,
                values=(self.result[1][i][0], self.result[1][i][1],
                        self.result[1][i][2], self.result[1][i][3]))

        write_info = open("info.txt", "w+")
        info_string = "./caltool -info < filter.ics > info.txt"
        os.system(info_string)
        write_info.close()
        cal_info = open("info.txt", "r")
        cal_info_string = cal_info.read()

        self.log_text.config(state=NORMAL)
        self.log_text.insert(END, cal_info_string + "\n")
        self.log_text.see(END)
        self.log_text.config(state=DISABLED)
Example #4
0
    def todo_btn(self, event):
        todo_msg = Toplevel(width=300, height=400, background="pink")
        todo_msg.title("Todo List")
        todo_msg.minsize(300, 400)
        todo_frame = Frame(todo_msg, width=300, height=100, background="pink")
        todo_frame.pack(fill=X)
        todo_lbl = Label(todo_frame,
                         text="To-Do List",
                         font=("Helvetica Light", 14),
                         background="pink").pack(pady=10, expand=1)

        write_filter = open("filter.ics", "w+")
        filter_todo = "./caltool -filter t < %s > filter.ics" % (self.cur_file)
        os.system(filter_todo)
        cal_filter_string = write_filter.read()
        write_filter.close()
        self.todos = []
        cal_status = cal.readFile("filter.ics", self.todos)

        check_frame = Frame(todo_frame,
                            width=300,
                            height=200,
                            background="pink")
        check_frame.pack(fill=X)

        for i in range(1, len(self.todos[1])):
            test1 = Checkbutton(check_frame,
                                text=self.todos[1][i][3],
                                variable=i,
                                bg="pink").pack(fill=X, anchor="w", pady=5)

        done_btn = Button(check_frame,
                          text="Done",
                          command=todo_msg.destroy,
                          background="white").pack(fill=X,
                                                   pady=5,
                                                   expand=1,
                                                   padx=20,
                                                   anchor="s")
Example #5
0
    def open_btn(self, event):
        open_ok = IntVar()
        open_ok = 1
        if (self.saved == 0):
            new_file_name = filedialog.askopenfilename()
            if (new_file_name):
                open_ok = 0
        else:
            if askyesno(
                    "WAIT!",
                    "You haven't saved changes, do you still want to open a new file?"
            ) == TRUE:
                new_file_name = filedialog.askopenfilename()
                if (new_file_name):
                    open_ok = 0

        if (open_ok == 0):
            open(new_file_name, 'r')
            root.title("%s" % (new_file_name))
            self.cur_file = new_file_name
            self.show_button.config(state=NORMAL)
            self.extract_e.config(state=NORMAL)
            self.extract_x.config(state=NORMAL)
            self.menu_file.entryconfig("Save", state=NORMAL)
            self.menu_file.entryconfig("Save As...", state=NORMAL)
            self.menu_file.entryconfig("Combine", state=NORMAL)
            self.menu_file.entryconfig("Filter...", state=NORMAL)
            self.menu_todo.entryconfig("To-Do List...", state=NORMAL)
            self.menu_todo.entryconfig("Undo...", state=NORMAL)
            self.menu_data.entryconfig("Store All", state=NORMAL)
            self.menu_data.entryconfig("Store Selected", state=NORMAL)
            self.menu_data.entryconfig("Clear", state=NORMAL)
            self.menu_data.entryconfig("Status", state=NORMAL)
            self.menu_data.entryconfig("Query...", state=NORMAL)

            self.result = []
            cal_status = cal.readFile(new_file_name, self.result)
            self.current_fvp = []
            self.current_fvp = self.result
            self.saved = 0

            self.organizers = []
            cal.getOrganizers(new_file_name, self.result, self.organizers)

            self.events = []
            cal.getEvents(new_file_name, self.result, self.events)

            self.todos = []
            cal.getTodos(new_file_name, self.result, self.todos)

            self.prop_tree.delete(*self.prop_tree.get_children())
            size = (len(self.result[1]))
            for i in range(0, size):
                self.prop_tree.insert(
                    "",
                    END,
                    text=i + 1,
                    values=(self.result[1][i][0], self.result[1][i][1],
                            self.result[1][i][2], self.result[1][i][3]))

            write_info = open("temp.txt", "w+")
            info_string = "./caltool -info < %s > temp.txt" % (new_file_name)
            os.system(info_string)
            write_info.close()
            cal_info = open("temp.txt", "r")
            cal_info_string = cal_info.read()
            cal_info.close()

            self.log_text.config(state=NORMAL)
            self.log_text.insert(END, cal_info_string + "\n")
            self.log_text.see(END)
            self.log_text.config(state=DISABLED)
Example #6
0
    def store_selected(self):
        selected = self.prop_tree.focus()
        index = self.prop_tree.item(selected, "text")

        write_status = cal.writeSelected("temp.txt", self.result[0], index)

        self.selection = []
        selected_status = cal.readFile("temp.txt", self.selection)

        self.organizers_s = []
        cal.getOrganizers("temp.txt", self.selection, self.organizers_s)
        check = "SELECT org_id FROM ORGANIZER WHERE name = \"" + self.organizers[
            0][0][0] + "\";"
        cursor.execute(check)
        result = cursor.fetchone()
        if (result == None):
            org_string = "INSERT INTO ORGANIZER (org_id, name, contact) VALUES (NULL, '" + self.organizers[
                0][0][0] + "', '" + self.organizers[0][0][1] + "');"
            cursor.execute(org_string)

        if (self.selection[1][1][0] == "VEVENT"):
            self.events_s = []
            cal.getEvents("temp.txt", self.selection, self.events_s)

            check = "SELECT event_id FROM EVENT WHERE summary = '" + self.events_s[
                0][0][0] + "' AND start_time = '" + self.events_s[0][0][
                    1] + "';"
            cursor.execute(check)
            result = cursor.fetchone()

            if (result == None):
                if (self.events_s[0][0][3] != ""):
                    check = "SELECT org_id from ORGANIZER WHERE name = '" + self.events_s[
                        0][0][3] + "';"
                    cursor.execute(check)
                    result = cursor.fetchone()[0]
                    event_string = "INSERT INTO EVENT (event_id, summary, start_time, location, organizer) VALUES (NULL, \"" + self.events_s[
                        0][0][0] + "\", \"" + self.events_s[0][0][
                            1] + "\", \"" + self.events_s[0][0][
                                2] + "\", " + str(result) + ");"
                else:
                    event_string = "INSERT INTO EVENT (event_id, summary, start_time, location, organizer) VALUES (NULL, \"" + self.events_s[
                        0][0][0] + "\", \"" + self.events_s[0][0][
                            1] + "\", \"" + self.events_s[0][0][
                                2] + "\", NULL);"

                cursor.execute(event_string)

        elif (self.selection[1][1][0] == "VTODO"):
            self.todos_s = []
            cal.getTodos("temp.txt", self.selection, self.todos_s)

            check = "SELECT todo_id FROM TODO WHERE summary = '" + self.todos_s[
                0][0][0] + "';"
            cursor.execute(check)
            result = cursor.fetchone()

            if (result == None):
                if (self.todos_s[0][0][2] != ""):
                    check = "SELECT org_id from ORGANIZER WHERE name = '" + self.todos_s[
                        0][0][2] + "';"
                    cursor.execute(check)
                    result = cursor.fetchone()[0]
                    todo_string = "INSERT INTO TODO (todo_id, summary, priority, organizer) VALUES (NULL, \"" + self.todos_s[
                        0][0][0] + "\", " + str(
                            self.todos_s[0][0][1]) + ", " + str(result) + ");"
                else:
                    todo_string = "INSERT INTO TODO (todo_id, summary, priority, organizer) VALUES (NULL, \"" + self.todos_s[
                        0][0][0] + "\", " + str(
                            self.todos_s[0][0][1]) + ", NULL);"

                cursor.execute(todo_string)

        connect.commit()
        self.status_btn()
Example #7
0
def fileFilter(fvpTree):

    global curFileName, unsavedChanges
    #POP UP WINDOW

    #store result (filter/cancel) button click
    confirmFilter = IntVar()
    confirmFilter.set(0)

    #the pop up window
    winFilter = Toplevel(root)
    winFilter.title("Filter")
    
    filterType = StringVar("")
    #radio buttons to select type of filter
    radioE = ttk.Radiobutton(winFilter, text = "Events", variable = filterType, value = "e", command = lambda: butFilter.configure(state = NORMAL), state = NORMAL)
    radioT = ttk.Radiobutton(winFilter, text = "To-dos", variable = filterType, value = "t", command = lambda: butFilter.configure(state = NORMAL), state = NORMAL)
    radioE.pack()
    radioT.pack()
    
    #Frame for textboxes that store 'date to ' and 'date from' strings
    frameFromTo = Frame(winFilter)
    dateFrom = StringVar()
    dateTo = StringVar()
    dateFrom.set("")
    dateTo.set("")
    
    entryFrom = ttk.Entry(frameFromTo, textvariable=dateFrom)
    entryTo = ttk.Entry(frameFromTo, textvariable=dateTo)

    #lables for the text boxes
    fromLabel = ttk.Label(frameFromTo, text='From: ')
    toLabel = ttk.Label(frameFromTo, text='To: ')
    fromLabel.grid(row = 0, column = 0)
    entryFrom.grid(row = 0, column = 1)
    toLabel.grid(row = 1, column = 0)
    entryTo.grid(row = 1, column = 1)
    frameFromTo.pack()

    #frame for and the actual filter/cancel buttons
    buttonFrame = Frame(winFilter)
    butFilter = Button(buttonFrame, text = "Filter", command = lambda: confirm(winFilter,confirmFilter), state = DISABLED)
    butCancel = Button(buttonFrame, text = "Cancel", command = lambda: cancel(winFilter,confirmFilter))
    butFilter.pack(side = LEFT)
    butCancel.pack(side = LEFT)

    buttonFrame.pack()

    #make modal and non-resizeable
    winFilter.resizable(FALSE,FALSE)
    winFilter.bind("<Escape>", lambda e: winFilter.destroy())
    winFilter.grab_set()
    winFilter.wait_window(winFilter)
    #End POPUPWINDOW-----------------------------------------------------

    #On Confirm
    if (confirmFilter.get() == 1):
        filtCalData = []
        filtIndexes = []

        #Run caltool with  'date to' and 'date from' args
        dateFromstr = str(dateFrom.get())
        dateTostr = str(dateTo.get())
        kindCode = str(filterType.get())
        args = ["./caltool","-filter",kindCode]

        if (not dateFromstr.isspace() and len(dateFromstr) != 0):
            args.append("from")
            args.append(dateFromstr)

        if (not dateTostr.isspace() and len(dateTostr) != 0):
            args.append("to")
            args.append(dateTostr)

        inFile = open(curFilePath,"r")
        outFile = open("./tempOut.temp","w")
        errFile = open("./tempErr.temp","w")

        Pcaltool = subprocess.Popen(args,stdin = inFile, stdout = outFile ,stderr = errFile)
        Pcaltool.wait()
        inFile.close()
        outFile.close()
        errFile.close()

        # read temp file for errors
        errFile = open("./tempErr.temp","r")
        errors = errFile.read()
        errFile.close()

        #If there are no errors
        if (len(errors) == 0):

            #read file and collect inforamtion in a list
            status = "OK"
            status = cal.readFile("./tempOut.temp",filtCalData)

            #if there are no errors in reading
            if (status == "OK"):
                
                #create new calFile object
                filtCal = calFile(filtCalData[0],filtCalData[1],filtCalData[2])


                #write Success
                writeToTextLog(textLog,"&SEP&")
                writeToTextLog(textLog,"Filter \""+ curFileName+"\""+ " successful!\n")

                #add the new items to tree
                fvpTree.clear()
                showSelBut.configure(state=DISABLED)

                fvpTree.addCal(filtCal)
                updateTitlebar("xcal- *"+curFileName)
                unsavedChanges = 1;

            #output error to textLog
            else:
                status = "Failed to filter \""+curFileName+"\"\n" + status
                writeToTextLog(textLog,status)
        #output error to text log
        else:
            if (kindCode == "e"):
                kind = "events"
            else:
                kind = "to-dos"
            writeToTextLog(textLog,"&SEP&")
            writeToTextLog(textLog,"No "+kind+" found\n")
            writeToTextLog(textLog,"Error filtering "+kind+":\n")
        
        os.remove("tempOut.temp")
        os.remove("tempErr.temp")