def test_case(self): print "Get config file log.manager.conf from testB2SafeCmd.conf" print "Check Config Path = ", self.confpath try: logmanager = LogManager(self.confpath, "") logmanager.initializeLogger() logger = logmanager.getLogger() logfile = logmanager.getLogFile() except IOError as er: print "IOError, directory 'log' might not exist" print "Error: ", er return False logmanager.initializeQueue() queue = logmanager.getQueue() print print "Case 1: log message" self.assertTrue(self._read_log_last_line(logger, logfile)) print print "Case 2: push message in queue" queue.push("test-message") print print "Case 3: check queue size (should be 1)" self.assertEqual(len(queue), 1) print print "Case 4: push message in queue" queue.push("test-message-2") print print "Case 5: check queue size, again (should be 2)" self.assertEqual(len(queue), 2) print print "Case 6: pop message from queue (should be test-message)" self.assertEqual(queue.pop(), "test-message") print print "Case 7: check queue size, again (should be 1)" self.assertEqual(len(queue), 1) print print "Case 8: pop message from queue, again (should be test-message-2)" self.assertEqual(queue.pop(), "test-message-2") print print "Case 9: check queue size last time (should be 0)" self.assertEqual(len(queue), 0)
from info import (__author__, __appname__, __description__) from logmanager import LogManager def json_dumps(json_data, indent=4): return json.dumps(json_data, indent=indent) def call_after(func): def _wrapper(*args, **kwargs): return wx.CallAfter(func, *args, **kwargs) return _wrapper log_manager = LogManager(config_path="./", add_time=True) class WalletTaskBarICON(wx.adv.TaskBarIcon): def __init__( self, frame, title=__appname__, ): wx.adv.TaskBarIcon.__init__(self) self._title = title self.MainFrame = frame self.SetIcon(wx.Icon(get_icon_file()), self._title) self.Bind(wx.adv.EVT_TASKBAR_LEFT_DCLICK, self.on_double_click) # override
def htmlsil(data): p = re.compile(r'<.*?>') return p.sub('', data) def soyle(who,text,lang): text=htmlsil(text) logManager.writeLog(who+"\t\t> "+text) print who+"> "+text seslendir(text,lang) pass def seslendir(text,lang): os.system('python tts_google.py "'+text+'" '+lang+' 2>/dev/null'); logManager=LogManager() factory = ChatterBotFactory() bot=[] os.system("clear"); for x in range(2): pandoraid="b0dafd24ee35a477" name = raw_input(str(x+1)+". botun adı: ") bottypeno = raw_input(name+" isimli botun tipi [1:cleverbot/2:pandorabots/3:jabberwacky]: ") if bottypeno=="1": bottype="cleverbot" elif bottypeno=="2":
def __init__(self): super(MainWindow, self).__init__() if getattr(sys, 'frozen', False): # we are running in a |PyInstaller| bundle basedir = sys._MEIPASS else: basedir = os.path.dirname(__file__) loadUi(os.path.join(basedir, "qtyoutube-dl.ui"), self) self.setWindowIcon(QIcon(":qtyoutube-dl")) #load setting #self.cfg = QSettings("coolshou.idv", "qtyoutube-dl") #self._savepath = "" #self.loadSettings() ################################### cfgpath = os.path.join( QStandardPaths.writableLocation( QStandardPaths.ApplicationsLocation), "qtyoutube-dl") if not os.path.exists(cfgpath): os.mkdir(cfgpath) self.opt_manager = opt_manager(cfgpath) self.log_manager = LogManager(cfgpath, self.opt_manager.options['log_time']) self.download_manager = None self.update_thread = None self.app_icon = None #REFACTOR Get and set on __init__.py self._download_list = DownloadList() self._status_list = ListCtrl(self.STATUSLIST_COLUMNS) self._status_list.rowsInserted.connect(self._update_btns) #self._status_list.selectionChanged.connect(self._on_selectionChanged) self.tv_status.setModel(self._status_list) self.tv_status.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) self.tv_status.clicked.connect(self._on_clicked) #self._status_selection = self.tv_status.selectionModel(); #self._status_selection.selectionChanged.connect(self._on_selectionChanged) #self.tv_status.activated.connect(self._on_activated) # Set up youtube-dl options parser self._options_parser = OptionsParser() # Set the Timer self._app_timer = QTimer(self) self._app_timer.timeout.connect(self._on_timer) #upadte ui self.setSettings() #self._url_list = [] ############################################ #button #self.le_savepath.textChanged.connect(self.updateSavePath) self.path_combobox.currentTextChanged.connect(self.updateSavePath) ################################### # set bitmap bitmap_data = (("add", ":/add"), ("down", ":/down"), ("up", ":/up"), ("copy", ":/copy"), ("delete", ":/delete"), ("start", ":/get"), ("stop", ":/stop"), ("pause", ":/pause"), ("resume", ":/resume"), ("qtyoutube-dl", ":/qtyoutube-dl"), ("setting", ":/setting"), ("trash", ":/trash"), ("info", ":/info")) # ("pause", ":/pause"), # ("resume", ":/resume") self._bitmaps = {} for item in bitmap_data: target, name = item #self._bitmaps[target] = wx.Bitmap(os.path.join(self._pixmaps_path, name)) self._bitmaps[target] = QIcon(name) # Dictionary to store all the buttons # Set the data for all the wx.Button items # name, label, size, event_handler buttons_data = (("delete", self.DELETE_LABEL, (-1, -1), self._on_delete, self.pb_del), ("clear", self.DELETEALL_LABEL, (-1, -1), self._on_delAll, self.pb_delAll), ("up", self.UP_LABEL, (-1, -1), self._on_arrow_up, self.pb_up), ("down", self.DOWN_LABEL, (-1, -1), self._on_arrow_down, self.pb_down), ("start", self.START_LABEL, (-1, -1), self._on_start, self.pb_Start), ("savepath", "...", (35, -1), self._on_savepath, self.pb_savepath), ("add", self.ADD_LABEL, (-1, -1), self._on_add, self.pb_add)) #("play", self.PLAY_LABEL, (-1, -1), self._on_play, QPushButton), #("reload", self.RELOAD_LABEL, (-1, -1), self._on_reload, QPushButton), #("pause", self.PAUSE_LABEL, (-1, -1), self._on_pause, QPushButton), self._buttons = {} for item in buttons_data: name, label, size, evt_handler, parent = item #button = parent(self._panel, size=size) button = parent if parent == QPushButton: button.setText(label) # elif parent == wx.BitmapButton: # button.setToolTip(wx.ToolTip(label)) # if name in self._bitmaps: # #button.SetBitmap(self._bitmaps[name], wx.TOP) # button.SetBitmap(self._bitmaps[name], wx.TOP) if evt_handler is not None: #button.Bind(wx.EVT_BUTTON, evt_handler) button.clicked.connect(evt_handler) self._buttons[name] = button self._path_combobox = self.path_combobox #test data #self.te_urls.append("https://www.youtube.com/watch?v=a9V0nl_ezLw") self._initAction() self.show()