Exemplo n.º 1
0
def ndl_loop():
	ndutil.setTimezone()

	cnfManager = CnfManager()
	cnfManager.load('./ndl.cnf')
	cnfData = cnfManager.getCnfData()

	logManager = LogManager(cnfData['mode'], cnfData['logFile'])
	logManager.intLog('Iniatiating')

	netManager = NetManager()
	netManager.setLogManager(logManager)

	reactor.listenUDP(cnfData['port'], netManager)
	logManager.intLog('Listening Com Port')
	reactor.run()
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    def __init__(self):
        """Base class initializer.

        Initialize base class and manager classes. Manager classes and their methods form the Driftwood Scripting API.

        Attributes:
            config: ConfigManager instance.
            log: LogManager instance.
            database: DatabaseManager instance.
            filetype: Shortcut to filetype module.
            tick: TickManager instance.
            path: PathManager instance.
            cache: CacheManager instance.
            resource: ResourceManager instance.
            input: InputManager instance.
            window: WindowManager instance.
            entity: EntityManager instance.
            area: AreaManager instance.
            script: ScriptManager instance.

            keycode: Contains the SDL keycodes.

            running: Whether the mainloop should continue running. Set False to shut down the engine.
        """
        self.config = ConfigManager(self)
        self.log = LogManager(self)
        self.database = DatabaseManager(self)
        self.tick = TickManager(self)
        self.path = PathManager(self)
        self.cache = CacheManager(self)
        self.resource = ResourceManager(self)
        self.input = InputManager(self)
        self.window = WindowManager(self)
        self.entity = EntityManager(self)
        self.area = AreaManager(self)
        self.script = ScriptManager(self)

        # SDL Keycodes.
        self.keycode = keycode

        self.running = False
Exemplo n.º 5
0
import json
from os import path
from logmanager import LogManager

cwd = path.dirname(path.dirname(path.realpath(__file__)))
log = LogManager.get_global_log()


class PersistentData(object):
    data = {}
    stats_filename = cwd + "/.stats.json"

    @staticmethod
    def read():
        try:
            with open(PersistentData.stats_filename) as myfile:
                string = myfile.read().strip("\n")
                PersistentData.data = json.loads(string)

                if not PersistentData.data:
                    PersistentData.data = {}

                log.info("Successfully read from " +
                         PersistentData.stats_filename)
        except:
            log.error("Failed to read from " + PersistentData.stats_filename)
            PersistentData.data = {}

        if not PersistentData.exists("py-count"):
            print("Can't find py-count")
            PersistentData.set("py-count", 0)
Exemplo n.º 6
0
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":
Exemplo n.º 7
0
class Driftwood:
    """The top-level base class

    This class contains the top level manager class instances and the mainloop. The instance of this class is
    passed to scripts as an API reference.
    """

    def __init__(self):
        """Base class initializer.

        Initialize base class and manager classes. Manager classes and their methods form the Driftwood Scripting API.

        Attributes:
            config: ConfigManager instance.
            log: LogManager instance.
            database: DatabaseManager instance.
            filetype: Shortcut to filetype module.
            tick: TickManager instance.
            path: PathManager instance.
            cache: CacheManager instance.
            resource: ResourceManager instance.
            input: InputManager instance.
            window: WindowManager instance.
            entity: EntityManager instance.
            area: AreaManager instance.
            script: ScriptManager instance.

            keycode: Contains the SDL keycodes.

            running: Whether the mainloop should continue running. Set False to shut down the engine.
        """
        self.config = ConfigManager(self)
        self.log = LogManager(self)
        self.database = DatabaseManager(self)
        self.tick = TickManager(self)
        self.path = PathManager(self)
        self.cache = CacheManager(self)
        self.resource = ResourceManager(self)
        self.input = InputManager(self)
        self.window = WindowManager(self)
        self.entity = EntityManager(self)
        self.area = AreaManager(self)
        self.script = ScriptManager(self)

        # SDL Keycodes.
        self.keycode = keycode

        self.running = False

    def run(self):
        """Perform startup procedures and enter the mainloop.
        """
        # Only run if not already running.
        if not self.running:
            self.running = True

            # Execute the init function of the init script if present.
            if not self.path["init.py"]:
                self.log.msg("WARNING", "Driftwood", "init.py missing, nothing will happen")
            else:
                self.script.call("init.py", "init")

            # Escape key pauses the engine.
            self.input.register(self.keycode.SDLK_ESCAPE, self.__handle_pause)

            # This is the mainloop.
            while self.running:
                # Process SDL events.
                sdlevents = sdl2ext.get_events()
                for event in sdlevents:
                    if event.type == SDL_QUIT:
                        # Stop running.
                        self.running = False

                    elif event.type == SDL_KEYDOWN:
                        # Pass a keydown to the Input Manager.
                        self.input._key_down(event.key.keysym.sym)

                    elif event.type == SDL_KEYUP:
                        # Pass a keyup to the Input Manager.
                        self.input._key_up(event.key.keysym.sym)

                    elif event.type == SDL_WINDOWEVENT and event.window.event == SDL_WINDOWEVENT_EXPOSED:
                        self.window.refresh()

                # Process tick callbacks.
                self.tick.tick()

            print("Shutting down...")
            return 0

    def __handle_pause(self, keyevent):
        if keyevent == InputManager.ONDOWN:
            # Shift+Escape shuts down the engine.
            if self.input.pressed(self.keycode.SDLK_LSHIFT) or self.input.pressed(self.keycode.SDLK_RSHIFT):
                self.running = False

            else:
                self.tick.toggle_pause()
Exemplo n.º 8
0
Arquivo: app.py Projeto: gkany/pwallet
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
Exemplo n.º 9
0
    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()