class NotifActions(object): def __init__(self, actions=[]): self.actns = Dispatch("libsnarl25.Actions") self.actions = actions for action in actions: self.actns.Add(*action) def add(self, actn): self.actns.Add(*actn) self.actions.append(actn) return self.actns.Count() def remove(self, actn): if actn in self.actions: ix = self.actions.index(actn) self.actns.Remove(ix + 1) self.actions.pop(ix) return self.actns.Count() def makeEmpty(self): self.actns.MakeEmpty() self.actions = [] return self.actns.Count() def Actions(self): return self.actns
def get_connection(self): """ Create a new WMI connection """ self.logger.debug( u"Connecting to WMI server " u"(host={host}, namespace={namespace}, provider={provider}, username={username})." .format(host=self.host, namespace=self.namespace, provider=self.provider, username=self.username)) # Initialize COM for the current thread # WARNING: any python COM object (locator, connection, etc) created in a thread # shouldn't be used in other threads (can lead to memory/handle leaks if done # without a deep knowledge of COM's threading model). Because of this and given # that we run each query in its own thread, we don't cache connections additional_args = [] pythoncom.CoInitialize() if self.provider != ProviderArchitecture.DEFAULT: context = Dispatch("WbemScripting.SWbemNamedValueSet") context.Add("__ProviderArchitecture", self.provider) additional_args = [None, "", 128, context] locator = Dispatch("WbemScripting.SWbemLocator") connection = locator.ConnectServer(self.host, self.namespace, self.username, self.password, *additional_args) return connection
def LeerCtaCte(self, pos=0): """Leer la cuenta corriente generada a partir de la facturación Args: pos (int): posición de la cuenta corriente (0 a n) Returns: dict: elemento de la cuenta corriente: { 'cod_cta_cte': 2561, 'estado_cta_cte': 'Modificable', 'fecha_hora_estado': datetime.datetime(2019, 5, 13, 9, 25, 32), 'cuit_emisor': 20267565393, 'tipo_cbte': 201, 'nro_cbte': 22, 'punto_vta': 999 'cod_moneda': 'PES', 'importe_total_fc': Decimal('12850000'), 'saldo': Decimal('12850000'), 'saldo_aceptado': Decimal('0') } """ from win32com.client import Dispatch d = Dispatch('Scripting.Dictionary') cc = self.ctas_ctes.pop(pos) if pos < len(self.ctas_ctes) else {} for k, v in cc.items(): d.Add(k, str(v)) return d
def get_connection(self): """ Create a new WMI connection """ self.logger.debug( u"Connecting to WMI server (host=%s, namespace=%s, provider=%s, username=%s).", self.host, self.namespace, self.provider, self.username, ) additional_args = [] if self.provider != ProviderArchitecture.DEFAULT: context = Dispatch("WbemScripting.SWbemNamedValueSet") context.Add("__ProviderArchitecture", self.provider) additional_args = [None, "", 128, context] locator = Dispatch("WbemScripting.SWbemLocator") connection = locator.ConnectServer(self.host, self.namespace, self.username, self.password, *additional_args) return connection
class NotifClasses(object): def __init__(self, classes=[]): self.clss = Dispatch("libsnarl25.Classes") for cls in classes: self.add(*cls) def count(self): return self.clss.Count() def add(self, *cls): self.clss.Add(*cls) return self.clss.Count() def remove(self, cls): self.clss.Remove(cls) return self.clss.Count() def makeEmpty(self): self.clss.MakeEmpty() return self.clss.Count() def Classes(self): return self.clss