示例#1
0
 def disconnect(self):
     try:
         self._disconnect(self)
     except:
         pmnc.log.error(exc_string())  # log and ignore
     finally:
         TransactionalResource.disconnect(self)
示例#2
0
 def disconnect(self):
     try:
         self._disconnect(self)
     except:
         pmnc.log.error(exc_string()) # log and ignore
     finally:
         TransactionalResource.disconnect(self)
示例#3
0
 def disconnect(self):
     try:
         try:
             self._sync_adapter_command("EXIT")
         finally:
             self._stop_adapter(Timeout(min(5.0, pmnc.request.remain)))
     except:
         pmnc.log.error(exc_string()) # log and ignore
     finally:
         TransactionalResource.disconnect(self)
示例#4
0
    def __init__(self, name: str, *,
                 server_address: (str, int),
                 broadcast: bool):

        TransactionalResource.__init__(self, name)

        self._server_address = server_address
        self._broadcast = broadcast

        self._server_info = "{0:s} udp://{1[0]:s}:{1[1]:d}".\
                            format(name, self._server_address)
示例#5
0
    def connect(self):

        TransactionalResource.connect(self)

        self._socket = socket(AF_INET, SOCK_DGRAM)
        try:
            if self._broadcast:
                self._socket.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
            else:
                self._socket.connect(self._server_address)
        except:
            self._socket.close()
            raise
示例#6
0
    def __init__(self, name: str, *,
                 java: os_path.isfile,
                 arguments: tuple_of(str),
                 classpath: str,
                 jndi: dict_of(str, str),
                 factory: str,
                 queue: str,
                 username: str,
                 password: str):

        TransactionalResource.__init__(self, name)
        AdapterHost.__init__(self, "org.pythomnic.jms.Sender",
                             java = java, arguments = arguments, classpath = classpath,
                             jndi = jndi, factory = factory, queue = queue,
                             username = username, password = password)
        self._request_count = 0
示例#7
0
    def __init__(self, name: str, *,
                 target_directory: optional(str) = None,
                 temp_directory: optional(str) = None,
                 temp_extension: str,
                 file_permissions: by_regex("^(?:[r-][w-][x-]){3}$")):

        TransactionalResource.__init__(self, name)

        self._target_directory = target_directory
        self._temp_directory = temp_directory
        self._temp_suffix = ".{0:s}".format(temp_extension)

        self._perm_mask = 0
        for i, perm_flag in enumerate((S_IRUSR, S_IWUSR, S_IXUSR, S_IRGRP, S_IWGRP,
                                       S_IXGRP, S_IROTH, S_IWOTH, S_IXOTH)):
            if file_permissions[i] != "-":
                self._perm_mask |= perm_flag
示例#8
0
    def __init__(self,
                 name: str,
                 *,
                 server_address: (str, int),
                 connect_timeout: float,
                 database: valid_database,
                 username: optional(str) = None,
                 password: optional(str) = None):

        TransactionalResource.__init__(self, name)
        self._server_address = server_address
        self._connect_timeout = connect_timeout
        self._database = database
        self._username = username
        self._connection = MongoDB_Connection(server_address=server_address,
                                              auth_database=database,
                                              username=username,
                                              password=password)
示例#9
0
    def __init__(self, name: str, *,
                 source_addr_ton: byte,
                 source_addr_npi: byte,
                 source_addr: str,
                 asynchronous: bool,
                 pack_7bit: optional(bool) = None,
                 frag_method: optional(one_of("sar", "udh")) = None):

        TransactionalResource.__init__(self, name)

        self._interface_name = name.split("/", 1)[0]
        self._source_addr_ton = source_addr_ton
        self._source_addr_npi = source_addr_npi
        self._source_addr = source_addr
        self._asynchronous = asynchronous
        self._pack_7bit = pack_7bit or False
        self._frag_method = frag_method

        self._interface = None
示例#10
0
    def __init__(self,
                 name,
                 *,
                 server_address: (str, int),
                 connect_timeout: float,
                 ssl_key_cert_file: optional(os_path.isfile),
                 ssl_ca_cert_file: optional(os_path.isfile),
                 ssl_ciphers: optional(str) = None,
                 ssl_protocol: optional(
                     one_of("SSLv23", "TLSv1", "TLSv1_1", "TLSv1_2",
                            "TLS")) = None,
                 ssl_server_hostname: optional(str) = None,
                 ssl_ignore_hostname: optional(bool) = False,
                 extra_headers: dict_of(str, str),
                 http_version: str,
                 server_uri: str,
                 request_encoding: str,
                 allow_none: optional(bool) = False):

        TransactionalResource.__init__(self, name)

        self._server_uri = server_uri
        self._request_encoding = request_encoding
        self._allow_none = allow_none

        self._http_resource = \
            pmnc.protocol_http.Resource(name,
                                        server_address = server_address,
                                        connect_timeout = connect_timeout,
                                        ssl_key_cert_file = ssl_key_cert_file,
                                        ssl_ca_cert_file = ssl_ca_cert_file,
                                        ssl_ciphers = ssl_ciphers,
                                        ssl_protocol = ssl_protocol,
                                        ssl_server_hostname = ssl_server_hostname,
                                        ssl_ignore_hostname = ssl_ignore_hostname,
                                        extra_headers = extra_headers,
                                        http_version = http_version)
示例#11
0
 def begin_transaction(self, *args, **kwargs):
     TransactionalResource.begin_transaction(self, *args, **kwargs)
     self._db = pmnc.state.default_state_db(self.source_module_name)
     self._txn, self._commit, self._rollback = \
         pmnc.state.start_transaction(self.source_module_name)
示例#12
0
 def __init__(self, name: str, **config):
     TransactionalResource.__init__(self, name)
     self._connect = config.pop("connect", self._noop)
     self._disconnect = config.pop("disconnect", self._noop)
     self._config = config
示例#13
0
 def connect(self):
     TransactionalResource.connect(self)
     self._connect(self)
示例#14
0
 def _expired(self):
     return self._http_resource.expired or \
            TransactionalResource._expired(self)
示例#15
0
 def _expired(self):
     return not self._adapter_running() or \
            TransactionalResource._expired(self)
示例#16
0
 def connect(self):
     TransactionalResource.connect(self)
     self._interface = pmnc.interfaces.get_interface(self._interface_name)
     if self._interface is None:
         raise Exception("interface {0:s} is unavailable".format(self._interface_name))
示例#17
0
 def begin_transaction(self, *args, **kwargs):
     TransactionalResource.begin_transaction(self, *args, **kwargs)
     self._message_id = None
示例#18
0
 def disconnect(self):
     try:
         self._http_resource.disconnect()
     finally:
         TransactionalResource.disconnect(self)
示例#19
0
 def set_idle_timeout(self, idle_timeout):
     self._http_resource.set_idle_timeout(idle_timeout)
     TransactionalResource.set_idle_timeout(self, idle_timeout)
示例#20
0
 def _expired(self):
     return self._interface is None or self._interface.ceased or \
            TransactionalResource._expired(self)
示例#21
0
 def connect(self):
     TransactionalResource.connect(self)
     self._attrs = []
     self._http_resource.connect()
示例#22
0
 def connect(self):
     TransactionalResource.connect(self)
     connect_timeout = Timeout(
         min(self._connect_timeout, pmnc.request.remain))
     self._connection.connect(connect_timeout)
     self._attrs = []
示例#23
0
 def connect(self):
     TransactionalResource.connect(self)
     self._start_adapter("resource instance", self.name,
                         Timeout(pmnc.request.remain))
示例#24
0
 def disconnect(self):
     try:
         self._socket.close()
     finally:
         TransactionalResource.disconnect()
示例#25
0
 def __init__(self, name: str, **config):
     TransactionalResource.__init__(self, name)
     self._connect = config.pop("connect", self._noop)
     self._disconnect = config.pop("disconnect", self._noop)
     self._config = config
示例#26
0
 def reset_idle_timeout(self):
     self._http_resource.reset_idle_timeout()
     TransactionalResource.reset_idle_timeout(self)
示例#27
0
 def connect(self):
     TransactionalResource.connect(self)
     self._connect(self)
示例#28
0
 def set_max_age(self, max_age):
     self._http_resource.set_max_age(max_age)
     TransactionalResource.set_max_age(self, max_age)
示例#29
0
 def begin_transaction(self, *args, **kwargs):
     TransactionalResource.begin_transaction(self, *args, **kwargs)
     self._db = pmnc.state.default_state_db(self.source_module_name)
     self._txn, self._commit, self._rollback = pmnc.state.start_transaction(self.source_module_name)
示例#30
0
 def begin_transaction(self, *args, **kwargs):
     TransactionalResource.begin_transaction(self, *args, **kwargs)
     self._temp_filename = None
     self._overwrite = self._remove = None