コード例 #1
0
 def _worker(self):
     CoInitializeEx(COINIT_MULTITHREADED)
     handler = WithEvents(self.client, EventHandler)
     handler.setExchange(self)
     while not self._termination.isSet():
         PumpWaitingMessages()
         self._termination.wait(0.001)
     CoUninitialize()
コード例 #2
0
ファイル: smartcom.py プロジェクト: vlasenkov/smartcom
 def _worker(self):
     CoInitializeEx(COINIT_MULTITHREADED)
     handler = WithEvents(self.client, EventHandler)
     handler.setExchange(self)
     while not self._termination.isSet():
         PumpWaitingMessages()
         self._termination.wait(0.001)
     CoUninitialize()
コード例 #3
0
ファイル: OlAddin.py プロジェクト: clamwin/clamwin
 def Init(self, inspectors_collection):
     dbg_print('InspectorWithEvents:Init')
     self.event_handlers = []
     item = self.CurrentItem
     if item.Class == constants.olMail:
         # Create EventHandler for MailItem
         mailitem_events = WithEvents(item, MailItemsEvent)
         mailitem_events.Init(self)
         mailitem_events._DoNewObject(item)
         self.event_handlers.append(mailitem_events)
     ObjectWithEvents.Init(self, inspectors_collection)
コード例 #4
0
ファイル: OlAddin.py プロジェクト: ghostshellgnome/clamwin
 def Init(self, inspectors_collection):
     dbg_print('InspectorWithEvents:Init')
     self.event_handlers = []
     item = self.CurrentItem
     if item.Class == constants.olMail:
         # Create EventHandler for MailItem
         mailitem_events = WithEvents(item, MailItemsEvent)
         mailitem_events.Init(self)
         mailitem_events._DoNewObject(item)
         self.event_handlers.append(mailitem_events)
     ObjectWithEvents.Init(self, inspectors_collection)
コード例 #5
0
def simile(dir_file_list: list, sh_list: list) -> None:
    RASTR1 = Dispatch('Astra.Rastr')
    WithEvents(RASTR1, RastrEvents)
    RASTR2 = Dispatch('Astra.Rastr')
    WithEvents(RASTR2, RastrEvents)
    RASTR1.Load(1, dir_file_list[0], sh_list[0])
    RASTR2.Load(1, dir_file_list[1], sh_list[1])
    vetv_1 = RASTR1.Tables("vetv")
    vetv_2 = RASTR2.Tables("vetv")
    wb = Workbook()
    ws = wb.active
    ws.title = 'Ветви'
    START_ROW_LOAD = 2
    START_ROW_HEAD = 1
    ws[f'A{START_ROW_HEAD}'] = "Тип"
    ws[f'B{START_ROW_HEAD}'] = "N_нач"
    ws[f'C{START_ROW_HEAD}'] = "N_кон"
    ws[f'D{START_ROW_HEAD}'] = "N_п"
    ws[f'E{START_ROW_HEAD}'] = "Название"
    ws[f'F{START_ROW_HEAD}'] = "Дисп.назв."
    ws[f'G{START_ROW_HEAD}'] = "R,Ом"
    ws[f'H{START_ROW_HEAD}'] = "X,ОМ"
    ws[f'I{START_ROW_HEAD}'] = "B,мкСм"
    ws[f'J{START_ROW_HEAD}'] = "Кт/р"
    ws[f'K{START_ROW_HEAD}'] = "I_доп_обор_ДДТН"
    ws[f'L{START_ROW_HEAD}'] = "I_доп_обор_АДТН"
    ws[f'M{START_ROW_HEAD}'] = "Iдоп_25_ДДТН"
    ws[f'N{START_ROW_HEAD}'] = "Iдоп_25_АДТН"

    for i in range(0, vetv_1.Count):
        ws[f'A{i + START_ROW_LOAD}'] = vetv_1.Cols("tip").Z(i)
        ws[f'B{i + START_ROW_LOAD}'] = vetv_1.Cols("ip").Z(i)
        ws[f'C{i + START_ROW_LOAD}'] = vetv_1.Cols("iq").Z(i)
        ws[f'D{i + START_ROW_LOAD}'] = vetv_1.Cols("np").Z(i)
        ws[f'E{i + START_ROW_LOAD}'] = vetv_1.Cols("name").Z(i)
        ws[f'F{i + START_ROW_LOAD}'] = vetv_1.Cols("dname").Z(i)

        ws[f'G{i + START_ROW_LOAD}'] = vetv_1.Cols("r").Z(i)
        ws[f'H{i + START_ROW_LOAD}'] = vetv_1.Cols("x").Z(i)
        ws[f'I{i + START_ROW_LOAD}'] = vetv_1.Cols("b").Z(i)

        ws[f'J{i + START_ROW_LOAD}'] = vetv_1.Cols("ktr").Z(i)

        ws[f'K{i + START_ROW_LOAD}'] = vetv_1.Cols("i_dop_ob").Z(i)
        ws[f'L{i + START_ROW_LOAD}'] = vetv_1.Cols("i_dop_ob_av").Z(i)

        ws[f'M{i + START_ROW_LOAD}'] = vetv_1.Cols("i_dop").Z(i)
        ws[f'N{i + START_ROW_LOAD}'] = vetv_1.Cols("i_dop_av").Z(i)

    wb.save('ветви.xlsx')
 def Setup(self, plugin, eventHandler):
     self.plugin = plugin
     self.eventHandler = eventHandler
     try:
         self.comInstance = GetActiveObject("MediaJukebox Application")
         WithEvents(self.comInstance, self.eventHandler)
         self.eventHandler.comInstance = self.comInstance
     except:
         pass
コード例 #7
0
def simile2(dir_file_list: list, sh_list: list):
    RASTR1 = Dispatch('Astra.Rastr')
    WithEvents(RASTR1, RastrEvents)
    RASTR2 = Dispatch('Astra.Rastr')
    WithEvents(RASTR2, RastrEvents)
    RASTR1.Load(1, dir_file_list[0], sh_list[0])
    RASTR2.Load(1, dir_file_list[1], sh_list[1])
    vetv_1 = RASTR1.Tables("vetv")
    vetv_2 = RASTR2.Tables("vetv")
    list1 = []
    list2 = []
    for i in range(0, vetv_1.Count):
        val1 = str(vetv_1.Cols('dname').Z(i))
        list1.append(val1)

    for j in range(0, vetv_2.Count):
        val2 = str(vetv_2.Cols('dname').Z(j))
        list2.append(val2)

    dict_cols_rastr_excel = {
        "tip": "A", "ip": "B", "iq": "C", "np": "D", "name": "E", "dname": "F",
        "r": "G", "x": "H", "b": "I", "ktr": "J", "i_dop_ob": "K", "i_dop_ob_av": "L",
        "i_dop": "M", "i_dop_av": "N"
    }

    wb = load_workbook(filename='ветви.xlsx')
    ws = wb['Ветви']
    fill = PatternFill(start_color='FFFF0000',
                       end_color='FFFF0000',
                       fill_type='solid')
    for index, value in enumerate(list1):
        if value != '' or value != '0' or value != ' ':
            if value in list2:
                row_ = list2.index(value)
                for key in dict_cols_rastr_excel.keys():
                    value_old = ws[f"{dict_cols_rastr_excel[key]}{index + 2}"].value
                    value_rastr = vetv_2.Cols(key).Z(row_)
                    if (key != "tip") and (key != "ip") and (key != "iq") and (key != "np") and (key != "name") and (key != "dname"):
                        if value_old != value_rastr:
                            ws[f"{dict_cols_rastr_excel[key]}{index + 2}"].fill = fill
                    value_new = f'{value_old} ({value_rastr})'
                    ws[f"{dict_cols_rastr_excel[key]}{index + 2}"] = value_new

    wb.save(filename='ветви2.xlsx')
コード例 #8
0
ファイル: pylot_win_recorder.py プロジェクト: ynztyl10/pylt
        print '  <case>'
        url = args[1]
        post_data = args[4]
        headers = args[5]
        print '    <url>%s</url>' % url
        if post_data:
            print '    <method>POST</method>'
            print '    <body><![CDATA[%s]]></body>' % post_data
            if headers:
                print '    <add_header>%s</add_header>' % headers
        print "  </case>"
        stop_event.set()
    
    def OnQuit(self):
        global finished
        finished = True
        ie.Visible = 0
        stop_event.set()


ie = Dispatch('InternetExplorer.Application', EventSink)
ev = WithEvents(ie, EventSink)

ie.Visible = 1

print '<testcases>'
while not finished:
    pythoncom.PumpWaitingMessages()
    stop_event.wait(.05)
    stop_event.clear()
print '</testcases>'
コード例 #9
0
ファイル: OlAddin.py プロジェクト: clamwin/clamwin
            win32gui.MessageBox(
                GetWindow(),
                'An error occured whilst Loading ClamWin. Error: %s.' % str(e),
                'ClamWin Free Antivirus',
                win32con.MB_OK | win32con.MB_ICONERROR)
            print "An error occured whilst Loading ClamWin. Error: %s." % str(
                e)

        # Setup all our filters and hooks.  We used to do this in OnConnection,
        # but a number of 'strange' bugs were reported which I suspect would
        # go away if done during this later event - and this later place
        # does seem more "correct" than the initial OnConnection event.
        # Toolbar and other UI stuff must be setup once startup is complete.
        explorers = self.application.Explorers
        # and Explorers events so we know when new explorers spring into life.
        explorers_events = WithEvents(explorers, ExplorersEvent)
        explorers_events.Init(self)
        # And hook our UI elements to all existing explorers
        for i in range(explorers.Count):
            explorer = explorers.Item(i + 1)
            explorer = explorers_events._DoNewObject(explorer)
            explorer.OnFolderSwitch()
        self.event_handlers.append(explorers_events)

        inspectors = self.application.Inspectors
        # and Inspectors events so we know when new inspectors spring into life.
        inspectors_events = WithEvents(inspectors, InspectorsEvent)
        inspectors_events.Init(self)
        # And elements to all existing inspectors
        for i in range(inspectors.Count):
            inspector = inspectors.Item(i + 1)
コード例 #10
0
class OutlookAddin(ObjectsEvent):
    _com_interfaces_ = ['_IDTExtensibility2']
    _public_methods_ = []
    #    _reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER
    _reg_clsid_ = "{E77FA584-1433-4af3-800D-AEC49BCCCB11}"
    _reg_progid_ = "ClamWin.OutlookAddin"
    _reg_policy_spec_ = "win32com.server.policy.EventHandlerPolicy"

    def __init__(self):
        self.application = None
        # check the debug flag iun the registry
        global _DEBUG
        try:
            subkey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
                                     'Software\\ClamWin')
            _DEBUG = int(_winreg.QueryValueEx(subkey, "Debug")[0]) == 1
        except:
            _DEBUG = False

    def OnConnection(self, application, connectMode, addin, custom):
        dbg_print('OutlookAddin:OnConnection')
        # Handle failures during initialization so that we are not
        # automatically disabled by Outlook.
        locale.setlocale(locale.LC_NUMERIC, "C")  # see locale comments above
        try:
            self.application = application
            self.event_handlers = []  # create at OnStartupComplete

            if connectMode == constants.ext_cm_AfterStartup:
                # We are being enabled after startup, which means we don't get
                # the 'OnStartupComplete()' event - call it manually so we
                # bootstrap code that can't happen until startup is complete.
                self.OnStartupComplete(None)
        except:
            print "Error connecting to Outlook!"
            traceback.print_exc()
            print "There was an error initializing the ClamWin addin\r\n\r\n"\
                "Please re-start Outlook and try again."

    def OnStartupComplete(self, custom):
        dbg_print('OutlookAddin:OnStartupComplete')
        Utils.CreateProfile()
        # display SplashScreen
        try:
            config_file = os.path.join(Utils.GetProfileDir(True),
                                       'ClamWin.conf')
            if not os.path.isfile(config_file):
                config_file = 'ClamWin.conf'
            config = Config.Settings(config_file)
            config.Read()

            if config.Get('EmailScan', 'ScanOutgoing') == '1' or \
                config.Get('EmailScan', 'ScanIncoming') == '1':
                # load clamav db
                try:
                    pyc.setDBPath(config.Get('ClamAV', 'Database'))
                    pyc.setDBTimer(pyc.SELFCHECK_ALWAYS)
                    pyc.loadDB()
                except Exception, e:
                    raise ScanError(
                        'ClamWin Error occured whilst loading virus database: %s'
                        % str(e))
                dbg_print('Database has been loaded from %s' %
                          config.Get('ClamAV', 'Database'))

                #show splashcreen
                splash = os.path.join(Utils.GetCurrentDir(False),
                                      "img\\Splash.bmp")
                if (config.Get('EmailScan', 'ShowSplash') == '1'):
                    SplashScreen.ShowSplashScreen(splash, 5)
        except Exception, e:
            print "An error occured whilst displaying the spashscreen Error: %s." % str(
                e)

        # Setup all our filters and hooks.  We used to do this in OnConnection,
        # but a number of 'strange' bugs were reported which I suspect would
        # go away if done during this later event - and this later place
        # does seem more "correct" than the initial OnConnection event.
        # Toolbar and other UI stuff must be setup once startup is complete.
        explorers = self.application.Explorers
        # and Explorers events so we know when new explorers spring into life.
        explorers_events = WithEvents(explorers, ExplorersEvent)
        explorers_events.Init(self)
        # And hook our UI elements to all existing explorers
        for i in range(explorers.Count):
            explorer = explorers.Item(i + 1)
            explorer = explorers_events._DoNewObject(explorer)
            explorer.OnFolderSwitch()
        self.event_handlers.append(explorers_events)

        inspectors = self.application.Inspectors
        # and Inspectors events so we know when new inspectors spring into life.
        inspectors_events = WithEvents(inspectors, InspectorsEvent)
        inspectors_events.Init(self)
        # And elements to all existing inspectors
        for i in range(inspectors.Count):
            inspector = inspectors.Item(i + 1)
            inspector = inspectors_events._DoNewObject(inspector)
        self.event_handlers.append(inspectors_events)
        # release application object otherwise Outlook2003 won't
        # shutdown if we are running in out-of-process EXE
        self.application = None
コード例 #11
0
            print('[Error]', description)
        elif code == 3:
            print('[Warning]', description)
        elif code == 4:
            print('[Lightbulb]', description)
        elif code == 5:
            print('[Info]', description)
        else:
            print([code, description])

    def Onprot(self, message):
        print(message)


RASTR = Dispatch('Astra.Rastr')
WithEvents(RASTR, RastrEvents)

SHABLON_RG2 = r'C:\Program Files\RastrWin3\RastrWin3\SHABLON\режим.rg2'
SHABLON_RST = r'C:\Program Files\RastrWin3\RastrWin3\SHABLON\динамика.rst'

FILE_PATH_RASTR = r'Зимний минимум 2027 минус 31.rst'


def dir_name(file: str):
    path_file = os.path.dirname(file)
    file_basename = os.path.basename(file)
    file_name, file_extension = os.path.splitext(file_basename)
    return path_file, file_name, file_extension


def corr_dname_vetv_model(FILE_PATH_RASTR: str, SHABLON: str):
コード例 #12
0
            print('[Error]', description)
        elif code == 3:
            print('[Warning]', description)
        elif code == 4:
            print('[Lightbulb]', description)
        elif code == 5:
            print('[Info]', description)
        else:
            print([code, description])

    def Onprot(self, message):
        print(message)


RASTR_1 = Dispatch('Astra.Rastr')
WithEvents(RASTR_1, RastrEvents)

RASTR_2 = Dispatch('Astra.Rastr')
WithEvents(RASTR_2, RastrEvents)


def move():
    rastr_win1 = RASTR_1
    rastr_win2 = RASTR_2
    # wb = Workbook()
    # ws = wb.active
    SHABLON_RST = r'C:\Program Files\RastrWin3\RastrWin3\SHABLON\динамика.rst'
    SHABLON_RG2 = r'C:\Program Files\RastrWin3\RastrWin3\SHABLON\режим.rg2'
    counter = 0
    rastr_win1.Load(1, 'БРМ лето 2021 МАКСИМУМ_7.rg2', SHABLON_RST)
    rastr_win2.Load(1, 'Зимний минимум 2027 минус 31.rst', SHABLON_RG2)