From 9db8236ef598e4dff7f9be2d7558b80ce1330c97 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 14 Jun 2009 00:07:43 +0200 Subject: new naming convention, cli structur --- Core.py | 236 ---------------------------------------------------------- pyLoadCli.py | 51 +++++++++++++ pyLoadCore.py | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pyLoadGui.py | 158 +++++++++++++++++++++++++++++++++++++++ pyMainGui.py | 158 --------------------------------------- 5 files changed, 445 insertions(+), 394 deletions(-) delete mode 100644 Core.py create mode 100644 pyLoadCli.py create mode 100644 pyLoadCore.py create mode 100755 pyLoadGui.py delete mode 100755 pyMainGui.py diff --git a/Core.py b/Core.py deleted file mode 100644 index 6db29a2ad..000000000 --- a/Core.py +++ /dev/null @@ -1,236 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -#Copyright (C) 2009 sp00b, sebnapi, RaNaN -# -#This program is free software; you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation; either version 3 of the License, -#or (at your option) any later version. -# -#This program is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -#See the GNU General Public License for more details. -# -#You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -### -CURRENT_VERSION = '0.1' - -import ConfigParser -import gettext -import logging -import logging.handlers -import time -import urllib2 -from glob import glob -from os import mkdir -from os import sep -from os.path import basename -from os.path import exists -from sys import exit -from sys import path -from sys import stdout -from time import sleep - -from module.Py_Load_File import PyLoadFile -from module.remote.RequestObject import RequestObject -from module.remote.SocketServer import ServerThread -from module.thread_list import Thread_List - -class Core(object): - """ pyLoad main - """ - def __init__(self): - self.config = {} - self.config['plugin_folder'] = "Plugins" - self.plugins_avaible = {} - - self.read_config() - - translation = gettext.translation("pyLoad", "locale", languages=[self.config['language']]) - translation.install(unicode=True) - - self.check_create(self.config['log_folder'], _("folder for logs")) - self.check_create(self.config['download_folder'], _("folder for downloads")) - self.check_create(self.config['link_file'], _("file for links"), False) - self.check_create(self.config['failed_file'], _("file for failed links"), False) - - self.init_logger(logging.DEBUG) # logging level - - self.check_update() - - self.logger.info(_("Downloadtime: %s") % self.is_dltime()) # debug only - - self.thread_list = Thread_List(self) - - path.append(self.config['plugin_folder']) - self.create_plugin_index() - - self.init_server() - - def read_config(self): - """ read config and sets preferences - """ - config = ConfigParser.SafeConfigParser() - config.read('config') - - for section in config.sections(): - for option in config.options(section): - self.config[option] = config.get(section, option) - self.config[option] = False if self.config[option].lower() == 'false' else self.config[option] - - def create_plugin_index(self): - for file_handler in glob(self.config['plugin_folder'] + sep + '*.py') + glob(self.config['plugin_folder'] + sep + 'DLC.pyc'): - if file_handler != self.config['plugin_folder'] + sep + "Plugin.py": - plugin_pattern = "" - plugin_file = basename(file_handler).replace('.pyc', '').replace('.py', '') - for line in open(file_handler, "r").readlines(): - if "props['pattern']" in line: - plugin_pattern = line.split("r\"")[1].split("\"")[0] - if plugin_pattern != "": - self.plugins_avaible[plugin_file] = plugin_pattern - self.logger.debug(plugin_file + _(" added")) - self.logger.info(_("created index of plugins")) - - - def _get_links(self, link_file): - """ funktion nur zum testen ohne gui bzw. tui - """ - links = open(link_file, 'r').readlines() - self.extend_links(links) - - def append_link(self, link): - if link not in self.thread_list.get_loaded_urls(): - self.__new_py_load_file(link.replace("\n", "")) - - def extend_links(self, links): - for link in links: - self.append_link(link) - - def check_update(self): - """checks newst version - """ - newst_version = urllib2.urlopen("http://pyload.nady.biz/files/version.txt").readline().strip() - if CURRENT_VERSION < newst_version: - self.logger.info(_("new update %s on pyload.org") % newst_version) #newer version out - elif CURRENT_VERSION == newst_version: - self.logger.info(_("newst version %s in use:") % CURRENT_VERSION) #using newst version - else: - self.logger.info(_("beta version %s in use:") % CURRENT_VERSION) #using beta version - - def check_create(self, check_name, legend, folder=True): - if not exists(check_name): - try: - if folder: - mkdir(check_name) - else: - open(check_name, "w") - print _("%s created") % legend - except: - print _("could not create %s") % legend - exit() - - def __new_py_load_file(self, url): - new_file = PyLoadFile(self, url) - new_file.download_folder = self.config['download_folder'] - self.thread_list.append_py_load_file(new_file) - return True - - def init_logger(self, level): - - file_handler = logging.handlers.RotatingFileHandler(self.config['log_folder'] + sep + 'log.txt', maxBytes=102400, backupCount=int(self.config['log_count'])) #100 kib * 5 - console = logging.StreamHandler(stdout) - - frm = logging.Formatter("%(asctime)s: %(levelname)-8s %(message)s", "%d.%m.%Y %H:%M:%S") - file_handler.setFormatter(frm) - console.setFormatter(frm) - - self.logger = logging.getLogger("log") # settable in config - - if self.config['file_log']: - self.logger.addHandler(file_handler) - - self.logger.addHandler(console) #if console logging - self.logger.setLevel(level) - - - def is_dltime(self): - start_h, start_m = self.config['start'].split(":") - end_h, end_m = self.config['end'].split(":") - - #@todo: little bug, when start and end time in same hour - hour, minute = time.localtime()[3:5] - - if hour > int(start_h) and hour < int(end_h): - return True - elif hour == int(start_h) and minute >= int(start_m): - return True - elif hour == int(end_h) and minute <= int(end_m): - return True - else: - return False - - def get_downloads(self): #only for debuging?!? - list = [] - for pyfile in self.thread_list.py_downloading: - download = {} - download['id'] = pyfile.id - download['name'] = pyfile.status.filename - download['speed'] = pyfile.status.get_speed() - download['eta'] = pyfile.status.get_ETA() - download['kbleft'] = pyfile.status.kB_left() - download['size'] = pyfile.status.size() - download['status'] = pyfile.status.type - list.append(download) - - return list - - def format_time(self, seconds): - seconds = int(seconds) - if seconds > 60: - hours, seconds = divmod(seconds, 3600) - minutes, seconds = divmod(seconds, 60) - return "%.2i:%.2i:%.2i" % (hours, minutes, seconds) - return _("%i seconds") % seconds - - def _test_print_status(self): - - if self.thread_list.py_downloading: - - for pyfile in self.thread_list.py_downloading: - if pyfile.status.type == 'downloading': - print pyfile.status.filename + ": speed is", int(pyfile.status.get_speed()), "kb/s" - print pyfile.status.filename + ": finished in", self.format_time(pyfile.status.get_ETA()) - elif pyfile.status.type == 'waiting': - print pyfile.status.filename + ": wait", self.format_time(pyfile.status.waituntil - time.time()) - - def start(self): - """ starts the machine - """ - self._get_links(self.config['link_file']) - while True: - #self.thread_list.status() - self._test_print_status() - self.server_test() - sleep(2) - if len(self.thread_list.threads) == 0: - pass #break - - def server_test(self): - obj = RequestObject() - obj.command = "update" - obj.data = self.get_downloads() - - self.server.push_all(obj) - - def init_server(self): - print _("Server Mode") - self.server = ServerThread(self) - self.server.start() - -if __name__ == "__main__": - testLoader = Core() - testLoader.start() diff --git a/pyLoadCli.py b/pyLoadCli.py new file mode 100644 index 000000000..d5c2d9f60 --- /dev/null +++ b/pyLoadCli.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +#Copyright (C) 2009 RaNaN, Willnix +# +#This program is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 3 of the License, +#or (at your option) any later version. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#See the GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +### +import time +import thread +import os +import sys +from module.remote.ClientSocket import SocketThread + +class pyLoadCli: + def __init__(self, adress, port, pw): + thread = SocketThread(adress, int(port), pw, self) + self.start() + + def start(self): + while True: + inp = raw_input() + print inp[-1] + + def data_arrived(self, obj): + """Handle incoming data""" + if obj.command == "update": + print str(obj.data) + + +if __name__ == "__main__": + if len(sys.argv) != 4: + address = raw_input("Adress:") + port = raw_input("Port:") + pw = raw_input("Password:") + cli = pyLoadCli(adress,port,pw) + else: + cli = pyLoadCli(*sys.argv[1:]) + + diff --git a/pyLoadCore.py b/pyLoadCore.py new file mode 100644 index 000000000..422bf013f --- /dev/null +++ b/pyLoadCore.py @@ -0,0 +1,236 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +#Copyright (C) 2009 sp00b, sebnapi, RaNaN +# +#This program is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 3 of the License, +#or (at your option) any later version. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#See the GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +### +CURRENT_VERSION = '0.1' + +import ConfigParser +import gettext +import logging +import logging.handlers +import time +import urllib2 +from glob import glob +from os import mkdir +from os import sep +from os.path import basename +from os.path import exists +from sys import exit +from sys import path +from sys import stdout +from time import sleep + +from module.Py_Load_File import PyLoadFile +from module.remote.RequestObject import RequestObject +from module.remote.SocketServer import ServerThread +from module.thread_list import Thread_List + +class Core(object): + """ pyLoad main + """ + def __init__(self): + self.config = {} + self.config['plugin_folder'] = "plugins" + self.plugins_avaible = {} + + self.read_config() + + translation = gettext.translation("pyLoad", "locale", languages=[self.config['language']]) + translation.install(unicode=True) + + self.check_create(self.config['log_folder'], _("folder for logs")) + self.check_create(self.config['download_folder'], _("folder for downloads")) + self.check_create(self.config['link_file'], _("file for links"), False) + self.check_create(self.config['failed_file'], _("file for failed links"), False) + + self.init_logger(logging.DEBUG) # logging level + + self.check_update() + + self.logger.info(_("Downloadtime: %s") % self.is_dltime()) # debug only + + self.thread_list = Thread_List(self) + + path.append(self.config['plugin_folder']) + self.create_plugin_index() + + self.init_server() + + def read_config(self): + """ read config and sets preferences + """ + config = ConfigParser.SafeConfigParser() + config.read('config') + + for section in config.sections(): + for option in config.options(section): + self.config[option] = config.get(section, option) + self.config[option] = False if self.config[option].lower() == 'false' else self.config[option] + + def create_plugin_index(self): + for file_handler in glob(self.config['plugin_folder'] + sep + '*.py') + glob(self.config['plugin_folder'] + sep + 'DLC.pyc'): + if file_handler != self.config['plugin_folder'] + sep + "Plugin.py": + plugin_pattern = "" + plugin_file = basename(file_handler).replace('.pyc', '').replace('.py', '') + for line in open(file_handler, "r").readlines(): + if "props['pattern']" in line: + plugin_pattern = line.split("r\"")[1].split("\"")[0] + if plugin_pattern != "": + self.plugins_avaible[plugin_file] = plugin_pattern + self.logger.debug(plugin_file + _(" added")) + self.logger.info(_("created index of plugins")) + + + def _get_links(self, link_file): + """ funktion nur zum testen ohne gui bzw. tui + """ + links = open(link_file, 'r').readlines() + self.extend_links(links) + + def append_link(self, link): + if link not in self.thread_list.get_loaded_urls(): + self.__new_py_load_file(link.replace("\n", "")) + + def extend_links(self, links): + for link in links: + self.append_link(link) + + def check_update(self): + """checks newst version + """ + newst_version = urllib2.urlopen("http://pyload.nady.biz/files/version.txt").readline().strip() + if CURRENT_VERSION < newst_version: + self.logger.info(_("new update %s on pyload.org") % newst_version) #newer version out + elif CURRENT_VERSION == newst_version: + self.logger.info(_("newst version %s in use:") % CURRENT_VERSION) #using newst version + else: + self.logger.info(_("beta version %s in use:") % CURRENT_VERSION) #using beta version + + def check_create(self, check_name, legend, folder=True): + if not exists(check_name): + try: + if folder: + mkdir(check_name) + else: + open(check_name, "w") + print _("%s created") % legend + except: + print _("could not create %s") % legend + exit() + + def __new_py_load_file(self, url): + new_file = PyLoadFile(self, url) + new_file.download_folder = self.config['download_folder'] + self.thread_list.append_py_load_file(new_file) + return True + + def init_logger(self, level): + + file_handler = logging.handlers.RotatingFileHandler(self.config['log_folder'] + sep + 'log.txt', maxBytes=102400, backupCount=int(self.config['log_count'])) #100 kib * 5 + console = logging.StreamHandler(stdout) + + frm = logging.Formatter("%(asctime)s: %(levelname)-8s %(message)s", "%d.%m.%Y %H:%M:%S") + file_handler.setFormatter(frm) + console.setFormatter(frm) + + self.logger = logging.getLogger("log") # settable in config + + if self.config['file_log']: + self.logger.addHandler(file_handler) + + self.logger.addHandler(console) #if console logging + self.logger.setLevel(level) + + + def is_dltime(self): + start_h, start_m = self.config['start'].split(":") + end_h, end_m = self.config['end'].split(":") + + #@todo: little bug, when start and end time in same hour + hour, minute = time.localtime()[3:5] + + if hour > int(start_h) and hour < int(end_h): + return True + elif hour == int(start_h) and minute >= int(start_m): + return True + elif hour == int(end_h) and minute <= int(end_m): + return True + else: + return False + + def get_downloads(self): #only for debuging?!? + list = [] + for pyfile in self.thread_list.py_downloading: + download = {} + download['id'] = pyfile.id + download['name'] = pyfile.status.filename + download['speed'] = pyfile.status.get_speed() + download['eta'] = pyfile.status.get_ETA() + download['kbleft'] = pyfile.status.kB_left() + download['size'] = pyfile.status.size() + download['status'] = pyfile.status.type + list.append(download) + + return list + + def format_time(self, seconds): + seconds = int(seconds) + if seconds > 60: + hours, seconds = divmod(seconds, 3600) + minutes, seconds = divmod(seconds, 60) + return "%.2i:%.2i:%.2i" % (hours, minutes, seconds) + return _("%i seconds") % seconds + + def _test_print_status(self): + + if self.thread_list.py_downloading: + + for pyfile in self.thread_list.py_downloading: + if pyfile.status.type == 'downloading': + print pyfile.status.filename + ": speed is", int(pyfile.status.get_speed()), "kb/s" + print pyfile.status.filename + ": finished in", self.format_time(pyfile.status.get_ETA()) + elif pyfile.status.type == 'waiting': + print pyfile.status.filename + ": wait", self.format_time(pyfile.status.waituntil - time.time()) + + def start(self): + """ starts the machine + """ + self._get_links(self.config['link_file']) + while True: + #self.thread_list.status() + self._test_print_status() + self.server_test() + sleep(2) + if len(self.thread_list.threads) == 0: + pass #break + + def server_test(self): + obj = RequestObject() + obj.command = "update" + obj.data = self.get_downloads() + + self.server.push_all(obj) + + def init_server(self): + print _("Server Mode") + self.server = ServerThread(self) + self.server.start() + +if __name__ == "__main__": + testLoader = Core() + testLoader.start() diff --git a/pyLoadGui.py b/pyLoadGui.py new file mode 100755 index 000000000..1342ed8f1 --- /dev/null +++ b/pyLoadGui.py @@ -0,0 +1,158 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +#Copyright (C) 2009 KingZero +# +#This program is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 3 of the License, +#or (at your option) any later version. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#See the GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +### + +from os import sep +from os.path import abspath +from os.path import dirname + +import wxversion +wxversion.select('2.8') + +import wx +import wx.lib.newevent +import wx.lib.sized_controls as sized_control +from module.remote.ClientSocket import SocketThread + +(DataArrived, EVT_DATA_ARRIVED) = wx.lib.newevent.NewEvent() + +class _Download_Dialog(sized_control.SizedDialog): + def __init__(self, parent, id): + sized_control.SizedDialog.__init__(self, parent, id, "Downloads hinzufügen", + style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) + + pane = self.GetContentsPane() + + self.links = wx.TextCtrl(pane, -1, style=wx.TE_MULTILINE, size=(500, 200)) + self.links.SetSizerProps(expand=True, proportion=1) + + self.SetButtonSizer(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL)) + + self.Fit() + self.SetMinSize(self.GetSize()) + + #Clipboard + self.data = wx.TextDataObject() + if wx.TheClipboard.Open(): + wx.TheClipboard.GetData(self.data) + for link in self.data.GetText().split('\n'): + if link.startswith("http"): + self.links.write(link + "\n") + wx.TheClipboard.Close() + +class _Upper_Panel(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent) + sizer = wx.BoxSizer(wx.HORIZONTAL) + download_liste = wx.ListCtrl(self, style=wx.LC_REPORT) + download_liste.InsertColumn(0, 'Name', width=250) + download_liste.InsertColumn(1, 'Status') + download_liste.InsertColumn(2, 'Groesse') + download_liste.InsertColumn(3, 'Uebertragen', width=100) + download_liste.InsertColumn(4, 'Prozent', width=100) + download_liste.InsertColumn(5, 'Dauer', width=100) + download_liste.InsertColumn(7, 'Geschwindigkeit', width=150) + + sizer.Add(download_liste, 1, wx.EXPAND) + self.SetSizer(sizer) + + +class _Lower_Panel(wx.Panel): + def __init__(self, parent): + wx.Panel.__init__(self, parent) + self.SetBackgroundColour(wx.BLACK) + + +class Pyload_Main_Gui(wx.Frame): + def __init__(self, parent, id, title="pyLoad"): + + wx.Frame.__init__(self, parent, id, title, size=(910, 500)) + + app_path = dirname(abspath(__file__)) + sep + + # socket + self.thread = SocketThread("localhost", 7272, "pwhere", self) + + + # Menubar + menubar = wx.MenuBar() + menu_file = wx.Menu() + submenu_exit = menu_file.Append(-1, 'Schliessen', 'pyLoad beenden') + menubar.Append(menu_file, '&Datei') + self.SetMenuBar(menubar) + + # Toolbar + toolbar = self.CreateToolBar() + toolbar.SetToolBitmapSize((32, 32)) + add = toolbar.AddLabelTool(2, '', wx.Bitmap(app_path + '/icons/add.png')) + delete = toolbar.AddLabelTool(3, '', wx.Bitmap(app_path + '/icons/del.png')) + start = toolbar.AddLabelTool(4, '', wx.Bitmap(app_path + '/icons/start.png')) + pause = toolbar.AddLabelTool(5, '', wx.Bitmap(app_path + '/icons/pause.png')) + stop = toolbar.AddLabelTool(6, '', wx.Bitmap(app_path + '/icons/stop.png')) + up = toolbar.AddLabelTool(7, '', wx.Bitmap(app_path + '/icons/up.png')) + down = toolbar.AddLabelTool(8, '', wx.Bitmap(app_path + '/icons/down.png')) + config = toolbar.AddLabelTool(9, '', wx.Bitmap(app_path + '/icons/setup.png')) + toolbar.Realize() + + splitter = wx.SplitterWindow(self) + panel_up = _Upper_Panel(splitter) + panel_down = _Lower_Panel(splitter) + splitter.SplitHorizontally(panel_up, panel_down, 300) + + # Binds + self.Bind(wx.EVT_MENU, self.exit_button_clicked, submenu_exit) + self.Bind(wx.EVT_TOOL, self.add_button_clicked, add) + self.Bind(EVT_DATA_ARRIVED, self.onUpdate) + + self.Centre() + self.Show(True) + + + def exit_button_clicked(self, event): + self.Close() + + def add_button_clicked(self, event): + #test + #self.thread.push_exec("get_downloads") + + adddownload = _Download_Dialog(None, -1) + result = adddownload.ShowModal() + adddownload.Destroy() + + def show_links(self, links): + for link in links: + wx.MessageDialog(self, str(link), 'info', style=wx.OK).ShowModal() + + def data_arrived(self, rep): + evt = DataArrived(obj=rep) + wx.PostEvent(self, evt) + + def onUpdate(self, evt): + + if evt.obj.function == "get_downloads": + pass + #self.show_links(evt.obj.response) + + if evt.obj.command == "update": + pass + #self.show_links(evt.obj.data) + +app = wx.App() +Pyload_Main_Gui(None, -1) +app.MainLoop() \ No newline at end of file diff --git a/pyMainGui.py b/pyMainGui.py deleted file mode 100755 index 1342ed8f1..000000000 --- a/pyMainGui.py +++ /dev/null @@ -1,158 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -#Copyright (C) 2009 KingZero -# -#This program is free software; you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation; either version 3 of the License, -#or (at your option) any later version. -# -#This program is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -#See the GNU General Public License for more details. -# -#You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -### - -from os import sep -from os.path import abspath -from os.path import dirname - -import wxversion -wxversion.select('2.8') - -import wx -import wx.lib.newevent -import wx.lib.sized_controls as sized_control -from module.remote.ClientSocket import SocketThread - -(DataArrived, EVT_DATA_ARRIVED) = wx.lib.newevent.NewEvent() - -class _Download_Dialog(sized_control.SizedDialog): - def __init__(self, parent, id): - sized_control.SizedDialog.__init__(self, parent, id, "Downloads hinzufügen", - style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) - - pane = self.GetContentsPane() - - self.links = wx.TextCtrl(pane, -1, style=wx.TE_MULTILINE, size=(500, 200)) - self.links.SetSizerProps(expand=True, proportion=1) - - self.SetButtonSizer(self.CreateStdDialogButtonSizer(wx.OK | wx.CANCEL)) - - self.Fit() - self.SetMinSize(self.GetSize()) - - #Clipboard - self.data = wx.TextDataObject() - if wx.TheClipboard.Open(): - wx.TheClipboard.GetData(self.data) - for link in self.data.GetText().split('\n'): - if link.startswith("http"): - self.links.write(link + "\n") - wx.TheClipboard.Close() - -class _Upper_Panel(wx.Panel): - def __init__(self, parent): - wx.Panel.__init__(self, parent) - sizer = wx.BoxSizer(wx.HORIZONTAL) - download_liste = wx.ListCtrl(self, style=wx.LC_REPORT) - download_liste.InsertColumn(0, 'Name', width=250) - download_liste.InsertColumn(1, 'Status') - download_liste.InsertColumn(2, 'Groesse') - download_liste.InsertColumn(3, 'Uebertragen', width=100) - download_liste.InsertColumn(4, 'Prozent', width=100) - download_liste.InsertColumn(5, 'Dauer', width=100) - download_liste.InsertColumn(7, 'Geschwindigkeit', width=150) - - sizer.Add(download_liste, 1, wx.EXPAND) - self.SetSizer(sizer) - - -class _Lower_Panel(wx.Panel): - def __init__(self, parent): - wx.Panel.__init__(self, parent) - self.SetBackgroundColour(wx.BLACK) - - -class Pyload_Main_Gui(wx.Frame): - def __init__(self, parent, id, title="pyLoad"): - - wx.Frame.__init__(self, parent, id, title, size=(910, 500)) - - app_path = dirname(abspath(__file__)) + sep - - # socket - self.thread = SocketThread("localhost", 7272, "pwhere", self) - - - # Menubar - menubar = wx.MenuBar() - menu_file = wx.Menu() - submenu_exit = menu_file.Append(-1, 'Schliessen', 'pyLoad beenden') - menubar.Append(menu_file, '&Datei') - self.SetMenuBar(menubar) - - # Toolbar - toolbar = self.CreateToolBar() - toolbar.SetToolBitmapSize((32, 32)) - add = toolbar.AddLabelTool(2, '', wx.Bitmap(app_path + '/icons/add.png')) - delete = toolbar.AddLabelTool(3, '', wx.Bitmap(app_path + '/icons/del.png')) - start = toolbar.AddLabelTool(4, '', wx.Bitmap(app_path + '/icons/start.png')) - pause = toolbar.AddLabelTool(5, '', wx.Bitmap(app_path + '/icons/pause.png')) - stop = toolbar.AddLabelTool(6, '', wx.Bitmap(app_path + '/icons/stop.png')) - up = toolbar.AddLabelTool(7, '', wx.Bitmap(app_path + '/icons/up.png')) - down = toolbar.AddLabelTool(8, '', wx.Bitmap(app_path + '/icons/down.png')) - config = toolbar.AddLabelTool(9, '', wx.Bitmap(app_path + '/icons/setup.png')) - toolbar.Realize() - - splitter = wx.SplitterWindow(self) - panel_up = _Upper_Panel(splitter) - panel_down = _Lower_Panel(splitter) - splitter.SplitHorizontally(panel_up, panel_down, 300) - - # Binds - self.Bind(wx.EVT_MENU, self.exit_button_clicked, submenu_exit) - self.Bind(wx.EVT_TOOL, self.add_button_clicked, add) - self.Bind(EVT_DATA_ARRIVED, self.onUpdate) - - self.Centre() - self.Show(True) - - - def exit_button_clicked(self, event): - self.Close() - - def add_button_clicked(self, event): - #test - #self.thread.push_exec("get_downloads") - - adddownload = _Download_Dialog(None, -1) - result = adddownload.ShowModal() - adddownload.Destroy() - - def show_links(self, links): - for link in links: - wx.MessageDialog(self, str(link), 'info', style=wx.OK).ShowModal() - - def data_arrived(self, rep): - evt = DataArrived(obj=rep) - wx.PostEvent(self, evt) - - def onUpdate(self, evt): - - if evt.obj.function == "get_downloads": - pass - #self.show_links(evt.obj.response) - - if evt.obj.command == "update": - pass - #self.show_links(evt.obj.data) - -app = wx.App() -Pyload_Main_Gui(None, -1) -app.MainLoop() \ No newline at end of file -- cgit v1.2.3