예제 #1
0
    def __init__(self, host, port, quiet, **kwargs):
        Server32.__init__(
            self, os.path.join(os.path.dirname(__file__), 'dotnet_lib32.dll'),
            'net', host, port, quiet)

        self.BasicMath = self.lib.DotNetMSL.BasicMath()
        self.ArrayManipulation = self.lib.DotNetMSL.ArrayManipulation()
예제 #2
0
    def __init__(self, host, port, **kwargs):

        # comtypes will try to import numpy to see if it is available.
        # Since Client64 passes its sys.path to Server32 the modules that
        # are available to Client64 to import are also available to Server32.
        # Therefore, we don't want this test to fail because the Python
        # environment that is running Client64 has numpy installed.
        # (This only appeared to be an issue when Client64 runs on Python 3.5)
        Server32.remove_site_packages_64bit()

        super(Shell32, self).__init__('WScript.Shell', 'com', host, port)

        self._environ = self.lib.Environment('System')
    def __init__(self, host, port, **kwargs):
        path = os.path.join(Server32.examples_dir(), 'cpp_lib32')
        super(Print32, self).__init__(path, 'cdll', host, port)

        if kwargs['show'] == 'True':
            print('this is a message')
            print('there is a problem', file=sys.stderr)
예제 #4
0
    def __init__(self, host, port, quiet, **kwargs):
        """
        A wrapper around 32-bit LCDriver.dll library.

        Parameters
        ----------
        host : str
            The IP address of the server.
        port : int
            The port to open on the server.
        quiet : bool
            Whether to hide :data:`sys.stdout` messages from the server.
        """
        Server32.__init__(self, 'C:\Program Files\ARCoptix\ARCoptix LC Driver 1.2\LCDriver.dll',
                            'net', host, port, quiet)
        # Need True flag to always open as if we might connect multiple LC driver devices
        self.lcdriver = self.lib.ARCoptix.LCdriver.LCdriver(True)
예제 #5
0
def test_is_interpreter():
    r = Running64()

    interpreter = r.interpreter()
    assert isinstance(interpreter, bool)
    assert interpreter

    is_interpreter = r.is_interpreter()
    assert isinstance(is_interpreter, bool)
    assert is_interpreter

    assert not Server32.is_interpreter()
예제 #6
0
    def __init__(self, host, port, **kwargs):

        # comtypes will try to import numpy to see if it is available.
        # Since Client64 passes its sys.path to Server32 the modules that
        # are available to Client64 to import are also available to Server32.
        # Therefore, we don't want this test to fail because the Python
        # environment that is running Client64 has numpy installed.
        # (This only appeared to be an issue when Client64 runs on Python 3.5)
        path = Server32.remove_site_packages_64bit()

        super(FileSystemObjectServer, self).__init__('Scripting.FileSystemObject', 'com', host, port)

        # put 'site-packages' back in
        if path:
            sys.path.append(path)

        self.temp_file = os.path.join(tempfile.gettempdir(), 'msl-loadlib-FileSystemObject.txt')
예제 #7
0
def test_protocol():
    args = (None, True, False, 1, -2.0, 5 - 6j, [1, [2., 'hello']], {
        'one': '1',
        'two': 2
    })
    kwargs = {
        'None': None,
        'True': True,
        'False': False,
        'Int': 1,
        'Float': -2.0,
        'Complex': 5 - 6j,
        'List': [1, [2., 'hello']],
        'Dict': {
            'one': '1',
            'two': 2
        },
    }

    # determine the maximum pickle protocol allowed based on
    # Python versions that are used by the server and the client
    server_version = re.match(r'Python\s(\d+)\.(\d+)', Server32.version())
    server_major, server_minor = map(int, server_version.groups())
    client_major, client_minor = sys.version_info[:2]
    major = min(server_major, client_major)
    minor = min(server_minor, client_minor)
    if major == 2:
        max_protocol = 2
    elif major == 3 and minor < 4:
        max_protocol = 3
    elif major == 3 and minor < 8:
        max_protocol = 4
    else:
        max_protocol = 5

    for protocol in list(range(10)):
        if protocol > max_protocol:
            with pytest.raises((Server32Error, ValueError),
                               match=r'pickle protocol'):
                Bounce64(protocol)
        else:
            b = Bounce64(protocol)
            a, k = b.bounce(*args, **kwargs)
            assert a == args
            assert k == kwargs
예제 #8
0
 def __init__(self, host, port):
     path = os.path.join(Server32.examples_dir(), 'cpp_lib32')
     super(Site32, self).__init__(path, 'cdll', host, port)
예제 #9
0
 def __init__(self, host, port, quiet):
     # even though this is a *dummy* class that does not call a shared library
     # we still need to provide a library file that exists. Use the C++ library.
     Server32.__init__(self,
                       os.path.join(os.path.dirname(__file__), 'cpp_lib32'),
                       'cdll', host, port, quiet)
예제 #10
0
 def __init__(self, host, port, quiet):
     Server32.__init__(self, os.path.join(os.path.dirname(__file__), 'dotnet_lib32.dll'),
                       'net', host, port, quiet)
예제 #11
0
import os
import subprocess

from msl.loadlib import Server32, Client64, SERVER_FILENAME
from msl.examples.loadlib import EXAMPLES_DIR

if Server32.is_interpreter():

    def skipif_no_server32(*args):
        pass
else:
    from conftest import skipif_no_server32


class Quiet32(Server32):
    def __init__(self, host, port, quiet, **kwargs):
        path = os.path.join(Server32.examples_dir(), 'cpp_lib32')
        super(Quiet32, self).__init__(path, 'cdll', host, port, quiet)
        self._kwargs = kwargs

    def add(self, a, b):
        return self.lib.add(a, b)

    def kwargs(self):
        return self._kwargs


class Quiet64(Client64):
    def __init__(self, **kwargs):
        super(Quiet64, self).__init__(__file__, **kwargs)
예제 #12
0
 def __init__(self, host, port, quiet, **kwargs):
     # load any dll since it won't be called
     Server32.__init__(self, 'cpp_lib32', 'cdll', host, port, quiet)
     self.kwargs = kwargs
예제 #13
0
 def __init__(self, host, port, **kwargs):
     # load any dll since it won't be called
     path = os.path.join(Server32.examples_dir(), 'cpp_lib32')
     super(ArgParse32, self).__init__(path, 'cdll', host, port)
     self.kwargs = kwargs
예제 #14
0
from msl.loadlib import LoadLibrary, Server32

# comtypes on the 32-bit server will try to import numpy
# remove site-packages before importing msl.loadlib.activex
if Server32.is_interpreter():
    Server32.remove_site_packages_64bit()

from msl.loadlib.activex import Application

prog_id = 'MediaPlayer.MediaPlayer.1'


class ActiveX(Server32):
    def __init__(self, host, port, **kwargs):
        super(ActiveX, self).__init__(prog_id, 'activex', host, port)

    def this(self):
        return self.lib.IsSoundCardEnabled()

    def static(self):
        return Application.load(prog_id).IsSoundCardEnabled()

    def create(self):
        return Application().load(prog_id).IsSoundCardEnabled()

    def parent(self):
        app = Application()
        return app.load(prog_id, parent=app).IsSoundCardEnabled()

    def panel(self):
        app = Application()
 def __init__(self, host, port, **kwargs):
     # this class would not instantiate if Server32.examples_dir()
     # was incorrect, so the fact that the server starts already
     # demonstrates that this test passes
     path = os.path.join(Server32.examples_dir(), 'cpp_lib32')
     super(Ex32, self).__init__(path, 'cdll', host, port)
예제 #16
0
 def __init__(self, host, port, quiet, **kwargs):
     # By not specifying the extension of the library file the server will open
     # the appropriate file based on the operating system.
     Server32.__init__(
         self, os.path.join(os.path.dirname(__file__), 'fortran_lib32'),
         'cdll', host, port, quiet)
def test_examples_dir():
    assert Server32.examples_dir() == EXAMPLES_DIR

    e = Ex64()
    assert e.examples_dir() == EXAMPLES_DIR
    assert e.ex_dir() == EXAMPLES_DIR
예제 #18
0
 def __init__(self, host, port, quiet, **kwargs):
     Server32.__init__(
         self, os.path.join(os.path.dirname(__file__), 'labview_lib32.dll'),
         'cdll', host, port, quiet)
예제 #19
0
 def __init__(self, host, port, quiet, **kwargs):
     Server32.__init__(self, 'C:/Windows/SysWOW64/kernel32.dll', 'windll',
                       host, port, quiet)
 def __init__(self, host, port, quiet, **kwargs):
     # Load the 'cpp_lib32' shared-library file using ctypes.CDLL
     Server32.__init__(self, ('%s\\tillimic.dll' % path11), 'cdll', host, port, quiet)
예제 #21
0
 def __init__(self, host, port, quiet, **kwargs):
     path = os.path.join(Server32.examples_dir(), 'cpp_lib32')
     super(Quiet32, self).__init__(path, 'cdll', host, port, quiet)
     self._kwargs = kwargs
예제 #22
0
    def __init__(self, host, port):
        path = os.path.join(Server32.examples_dir(), 'cpp_lib32')
        super(Property32, self).__init__(path, 'cdll', host, port)

        self.three = self.lib.add(1, 2)