def do_GET(self): self.web = None self.web = Web.Web() #web = Web.Web(self.clementine.GetInfo()) #TODO: clean up code and clear up beahaviour #print "_____________________" + self.path + "_____________________" #TODO: implement ability to start Clementine from WebUI or automaticly #print "Trying to start Clementine" #os.system("clementine &") if self.path.endswith("refresh") and self.connectToClementine(): self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() self.wfile.write(self.web.PrintInfo().encode('utf-8')) return elif self.path.endswith( "tracklist.html") and self.connectToClementine(): self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() self.wfile.write( self.web.PrintInfo2(self.clementine).encode('utf-8')) return else: if self.path.endswith(".png"): self.show_button() if self.path.endswith(".jpg") and self.connectToClementine(): self.show_cover() elif self.path.endswith(".css"): f = open('style.css') self.send_response(200) self.send_header('Content-type', 'text/css') self.end_headers() self.wfile.write(f.read().encode('utf-8')) f.close() else: self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() if self.connectToClementine(): backend = Functionality.Functionality( self.path, self.clementine) backend.run() self.web.printWebUI(self.wfile, self.clementine, backend) else: self.wfile.write(self.web.PrintError().encode('utf-8')) return
def test_pozitive(): handler = functionality.Functionality() # /skip [POST] def skip(): assert (handler.next() == 200) # /seek [POST] def seek(): # For the command line assert handler.cmd_scroll(1) == 200 # FF assert handler.cmd_scroll(5) == 200 # FFF assert handler.cmd_scroll(-1) == 200 # BB assert handler.cmd_scroll(-5) == 200 # BBB # For the GUI assert handler.scroll_video("ff") == 200 # FF assert handler.scroll_video("fff") == 200 # FFF assert handler.scroll_video("bb") == 200 # BB assert handler.scroll_video("bbb") == 200 # BBB # play / pause [POST] def start(): assert handler.cmd_start() == 200 # Start the music assert handler.cmd_stop() == 200 # Stop the music # Uses cmd_start() for the GUI assert handler.scroll_video("start") == 200 assert handler.is_music_playing() == False # Always false # /volume [GET] def volume(): assert handler.cmd_volume([0]) == 200 assert handler.cmd_volume([1]) == 200 assert handler.cmd_volume([2]) == 200 assert handler.cmd_volume([3]) == 200 assert handler.cmd_volume([4]) == 200 assert handler.cmd_volume([5]) == 200 assert handler.cmd_volume([6]) == 200 assert handler.cmd_volume([7]) == 200 assert handler.cmd_volume([8]) == 200 assert handler.cmd_volume([9]) == 200 assert handler.cmd_volume([10]) == 200 assert handler.cmd_volume([11]) == 400 # /cast [POST] (Only with local files) def cast(): assert handler.cmd_cast(["C:/Home/video.mp4"]) == 200 # Absolute path assert handler.cmd_cast(["path/video.mp4"]) == 200 # Relative path # Multiple absolute paths assert handler.cmd_cast(["C:/Home/video.mp4", "D:/Home/video.mp4"]) == 200 # Multiple relative paths assert handler.cmd_cast(["path/video.mp4", "/video.mp4"]) == 200 # /mcast [POST] (Only with local files) def mcast(): assert handler.cmd_mcast(["C:/Home/video.mp4" ]) is None # Absolute path assert handler.cmd_mcast(["path/video.mp4"]) is None # Relative path # Multiple absolute paths assert handler.cmd_mcast(["C:/Home/video.mp4", "D:/Home/video.mp4" ]) is None # Multiple relative paths assert handler.cmd_mcast(["path/video.mp4", "/video.mp4"]) is None skip() seek() start() volume() cast() mcast()
def __init__(self): # Handler self.handler = func.Functionality() self._job = None # ------------------------------Setting up the main window------------- main_window = tk.Tk() main_window.title("CliView") main_window.geometry("500x700") main_window.resizable(False, False) #main_window.iconbitmap("Pictures/icon.ico") It only works for Windows. main_window.tk.call('wm', 'iconphoto', main_window._w, ImageTk.PhotoImage(file='Pictures/icon.ico')) self.app = main_window #Background image foot_img = ImageTk.PhotoImage( Image.open("Pictures/background.png").resize((500, 700), Image.ANTIALIAS)) canvas = tk.Canvas(main_window, width=500, height=700) canvas.create_image(0, 0, anchor='nw', image=foot_img) canvas.image = foot_img canvas.place(x=0, y=0, relwidth=1, relheight=1) # Setting up frames logo_frame = tk.Frame(main_window, width=500, height=200) logo_frame.pack(side="top", pady=(5, 25)) input_frame = tk.Frame(main_window, width=200, height=50) input_frame.pack(anchor="center") links_frame = tk.Frame(main_window, width=500, height=200) links_frame.pack(side="top", anchor="center") control_frame = tk.Frame(main_window, width=200, height=50) control_frame.pack(anchor="center", pady=(70, 10)) sound_frame = tk.Frame(main_window, width=200, height=50, bg="white") sound_frame.pack(anchor="center") master_frame = tk.Frame(main_window, width=200, height=50) master_frame.pack(anchor="center", pady=(50, 0)) # Logo frame logo = ImageTk.PhotoImage( Image.open("Pictures/logo.png").resize((150, 150), Image.ANTIALIAS)) logo_label = tk.Label(logo_frame, image=logo) logo_label.image = logo logo_label.pack(anchor="center") # Links frame self.upload_links = ttk.Entry(input_frame, width=40) self.upload_links.grid(row=0, column=0, columnspan=2) upload_button = ttk.Button( input_frame, text="UPLOAD", width=13, command=lambda: self.upload(self.upload_links.get()) if self.upload_links.get() != "" else self.load_local_file()) upload_button.grid(row=0, column=3) cast_button = ttk.Button(input_frame, text="CAST ", command=lambda: self.cast() if self.link_list.size() > 0 else self.error( "Provide at least one link!")) cast_button.grid(row=0, column=4) self.link_list = tk.Listbox(links_frame, selectmode="extended", width=75, height=7) self.link_list.bind("<KeyRelease>", self.delete_element) self.link_list.pack(anchor="center") # Control frame bbb_icon = ImageTk.PhotoImage( Image.open("Pictures/bbb.png").resize((40, 40), Image.ANTIALIAS)) bb_icon = ImageTk.PhotoImage( Image.open("Pictures/bb.png").resize((40, 40), Image.ANTIALIAS)) ff_icon = ImageTk.PhotoImage( Image.open("Pictures/ff.png").resize((40, 40), Image.ANTIALIAS)) fff_icon = ImageTk.PhotoImage( Image.open("Pictures/fff.png").resize((40, 40), Image.ANTIALIAS)) self.strt_icon = ImageTk.PhotoImage( Image.open("Pictures/play.png").resize((40, 40), Image.ANTIALIAS)) self.stop_icon = ImageTk.PhotoImage( Image.open("Pictures/stop.png").resize((40, 40), Image.ANTIALIAS)) bbb_button = ttk.Button(control_frame, image=bbb_icon, command=lambda: self.scroll_video("bbb")) bbb_button.image = bbb_icon bb_button = ttk.Button(control_frame, image=bb_icon, command=lambda: self.scroll_video("bb")) bb_button.image = bb_icon self.start_button = ttk.Button( control_frame, image=self.strt_icon, command=lambda: self.scroll_video("start")) self.start_button.image = self.strt_icon ff_button = ttk.Button(control_frame, image=ff_icon, command=lambda: self.scroll_video("ff")) ff_button.image = ff_icon fff_button = ttk.Button(control_frame, image=fff_icon, command=lambda: self.scroll_video("fff")) fff_button.image = fff_icon bbb_button.grid(row=0, column=0) bb_button.grid(row=0, column=1) self.start_button.grid(row=0, column=2) ff_button.grid(row=0, column=3) fff_button.grid(row=0, column=4) # Sound frame style = ttk.Style() style.configure('TScale', background='white') sound_icon = ImageTk.PhotoImage( Image.open("Pictures/max_sound.png").resize((30, 30), Image.ANTIALIAS)) sound_label = tk.Label(sound_frame, image=sound_icon, bg="white") sound_label.image = sound_icon sound_label.grid(row=0, column=0) self.mixer = ttk.Scale(sound_frame, from_=LOW_V, to=HIGH_V, orient="horizontal", style='TScale', command=self.updateValue) self.mixer.set(START_V) self.mixer.grid(row=0, column=1) # Master frame next_button = ttk.Button(master_frame, text="Next", width=50, command=self.handler.next) save_button = ttk.Button(master_frame, text="Save", width=50, command=lambda: self.save_links() if self.link_list.size() > 0 else self.error( "Nothing can be saved!")) load_button = ttk.Button(master_frame, text="Load", width=50, command=lambda: self.load_links()) set_button = ttk.Button(master_frame, text="Settings", width=50, command=self.setting) exit_button = ttk.Button(master_frame, text="Exit", width=50, command=main_window.destroy) next_button.grid(row=0, column=0, columnspan=2) save_button.grid(row=1, column=0, columnspan=2) load_button.grid(row=2, column=0, columnspan=2) set_button.grid(row=3, column=0, columnspan=2) exit_button.grid(row=4, column=0, columnspan=2)
import sys import gui import functionality try: if len(sys.argv) > 1: handler = functionality.Functionality() if len(sys.argv[2:]) == 0: handler.commands[sys.argv[1]]() else: handler.commands[sys.argv[1]](sys.argv[2:]) else: _gui = gui.ResposeWriterGUI() _gui.start() except Exception as e: print(e)