temscript 2.0.1__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {temscript-2.0.1/temscript.egg-info → temscript-2.1.0}/PKG-INFO +15 -2
  2. {temscript-2.0.1 → temscript-2.1.0}/docs/changelog.rst +6 -0
  3. {temscript-2.0.1 → temscript-2.1.0}/docs/instrument.rst +7 -0
  4. {temscript-2.0.1 → temscript-2.1.0}/temscript/_com.py +24 -1
  5. {temscript-2.0.1 → temscript-2.1.0}/temscript/base_microscope.py +10 -2
  6. temscript-2.1.0/temscript/version.py +1 -0
  7. {temscript-2.0.1 → temscript-2.1.0/temscript.egg-info}/PKG-INFO +15 -2
  8. temscript-2.0.1/temscript/version.py +0 -1
  9. {temscript-2.0.1 → temscript-2.1.0}/LICENSE +0 -0
  10. {temscript-2.0.1 → temscript-2.1.0}/MANIFEST.in +0 -0
  11. {temscript-2.0.1 → temscript-2.1.0}/README.md +0 -0
  12. {temscript-2.0.1 → temscript-2.1.0}/docs/Makefile +0 -0
  13. {temscript-2.0.1 → temscript-2.1.0}/docs/about.rst +0 -0
  14. {temscript-2.0.1 → temscript-2.1.0}/docs/conf.py +0 -0
  15. {temscript-2.0.1 → temscript-2.1.0}/docs/index.rst +0 -0
  16. {temscript-2.0.1 → temscript-2.1.0}/docs/make.bat +0 -0
  17. {temscript-2.0.1 → temscript-2.1.0}/docs/microscope.rst +0 -0
  18. {temscript-2.0.1 → temscript-2.1.0}/docs/requirements.txt +0 -0
  19. {temscript-2.0.1 → temscript-2.1.0}/docs/restrictions.rst +0 -0
  20. {temscript-2.0.1 → temscript-2.1.0}/docs/server.rst +0 -0
  21. {temscript-2.0.1 → temscript-2.1.0}/pyproject.toml +0 -0
  22. {temscript-2.0.1 → temscript-2.1.0}/scripts/run_null_server.py +0 -0
  23. {temscript-2.0.1 → temscript-2.1.0}/scripts/test_camera_acquisition.py +0 -0
  24. {temscript-2.0.1 → temscript-2.1.0}/scripts/test_instrument.py +0 -0
  25. {temscript-2.0.1 → temscript-2.1.0}/scripts/test_json_encoder.py +0 -0
  26. {temscript-2.0.1 → temscript-2.1.0}/scripts/test_microscope.py +0 -0
  27. {temscript-2.0.1 → temscript-2.1.0}/setup.cfg +0 -0
  28. {temscript-2.0.1 → temscript-2.1.0}/setup.py +0 -0
  29. {temscript-2.0.1 → temscript-2.1.0}/temscript/__init__.py +0 -0
  30. {temscript-2.0.1 → temscript-2.1.0}/temscript/_instrument_com.py +0 -0
  31. {temscript-2.0.1 → temscript-2.1.0}/temscript/_instrument_stubs.py +0 -0
  32. {temscript-2.0.1 → temscript-2.1.0}/temscript/enums.py +0 -0
  33. {temscript-2.0.1 → temscript-2.1.0}/temscript/instrument.py +0 -0
  34. {temscript-2.0.1 → temscript-2.1.0}/temscript/marshall.py +0 -0
  35. {temscript-2.0.1 → temscript-2.1.0}/temscript/microscope.py +0 -0
  36. {temscript-2.0.1 → temscript-2.1.0}/temscript/null_microscope.py +0 -0
  37. {temscript-2.0.1 → temscript-2.1.0}/temscript/remote_microscope.py +0 -0
  38. {temscript-2.0.1 → temscript-2.1.0}/temscript/server.py +0 -0
  39. {temscript-2.0.1 → temscript-2.1.0}/temscript.egg-info/SOURCES.txt +0 -0
  40. {temscript-2.0.1 → temscript-2.1.0}/temscript.egg-info/dependency_links.txt +0 -0
  41. {temscript-2.0.1 → temscript-2.1.0}/temscript.egg-info/entry_points.txt +0 -0
  42. {temscript-2.0.1 → temscript-2.1.0}/temscript.egg-info/requires.txt +0 -0
  43. {temscript-2.0.1 → temscript-2.1.0}/temscript.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: temscript
3
- Version: 2.0.1
3
+ Version: 2.1.0
4
4
  Summary: TEM Scripting adapter for FEI microscopes
5
5
  Home-page: https://github.com/niermann/temscript
6
6
  Author: Tore Niermann
@@ -21,6 +21,19 @@ Classifier: Operating System :: OS Independent
21
21
  Requires-Python: >=3.4
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
+ Requires-Dist: numpy
25
+ Dynamic: author
26
+ Dynamic: author-email
27
+ Dynamic: classifier
28
+ Dynamic: description
29
+ Dynamic: description-content-type
30
+ Dynamic: home-page
31
+ Dynamic: license
32
+ Dynamic: platform
33
+ Dynamic: project-url
34
+ Dynamic: requires-dist
35
+ Dynamic: requires-python
36
+ Dynamic: summary
24
37
 
25
38
  # About
26
39
 
@@ -1,6 +1,12 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ Version 2.1.0
5
+ ^^^^^^^^^^^^^
6
+
7
+ * Changed default apartment model to COINIT_APARTMENTTHREADED to increase compatibility with comtypes
8
+ * COM initialization respects setting from sys.coinit_flags
9
+
4
10
  Version 2.0.1
5
11
  ^^^^^^^^^^^^^
6
12
 
@@ -13,6 +13,13 @@ The interface is described in detail in the scripting manual of your microscope
13
13
  The manual is your ultimate reference, this documentation will only describe the
14
14
  python wrapper to the COM interface.
15
15
 
16
+ The COM apartment model will automatically be initialized as ``COINIT_APARTMENTTHREADED``
17
+ (this changed in Version 2.1.0, it was ``COINIT_MULTITHREADED`` before). However, if the
18
+ apartment model was already initialized as ``COINIT_MULTITHREADED`` before `temscript`
19
+ was imported, `temscript` will also work. If you want a specific apartment model, set the
20
+ variable ``sys.coinit_flags`` before importing `temscript`.
21
+
22
+
16
23
  Enumerations
17
24
  ^^^^^^^^^^^^
18
25
 
@@ -6,6 +6,7 @@ __all__ = 'UUID', 'CLSCTX_ALL', 'IUnknown', 'co_create_instance', 'SafeArray', '
6
6
 
7
7
  # COM constants
8
8
  COINIT_MULTITHREADED = 0
9
+ COINIT_APARTMENTTHREADED = 2
9
10
  CLSCTX_ALL = 0x17
10
11
 
11
12
 
@@ -370,5 +371,27 @@ class SafeArray:
370
371
 
371
372
 
372
373
  _ole32 = ctypes.oledll.ole32
373
- _ole32.CoInitializeEx(None, ctypes.c_int(COINIT_MULTITHREADED))
374
374
  _oleauto = ctypes.windll.oleaut32
375
+
376
+ def initialize_com(flags=None):
377
+ RPC_E_CHANGED_MODE = -2147417850
378
+
379
+ # The comtypes package allows to specify the apartment model by
380
+ # setting sys.coinit_flags in advance. We copy this behavior.
381
+ if flags is None:
382
+ import sys
383
+ flags = getattr(sys, "coinit_flags", None)
384
+
385
+ if flags is None:
386
+ # If we don't have explicit flags, try STA first and fall back to MTA
387
+ # if COM is already initialized to MTA.
388
+ try:
389
+ _ole32.CoInitializeEx(None, ctypes.c_int(COINIT_APARTMENTTHREADED))
390
+ except WindowsError as exc:
391
+ if exc.winerror == RPC_E_CHANGED_MODE:
392
+ _ole32.CoInitializeEx(None, ctypes.c_int(COINIT_MULTITHREADED))
393
+ else:
394
+ # Otherwise, use the apartment model we got
395
+ _ole32.CoInitializeEx(None, flags)
396
+
397
+ initialize_com()
@@ -641,7 +641,11 @@ class BaseMicroscope(ABC):
641
641
  def get_indicated_camera_length(self):
642
642
  """
643
643
  Return (indicated) camera length in meters in diffraction modes.
644
- If microscope is in imaging mode, 0 is returned.
644
+
645
+ .. note::
646
+ The scripting manual states, that this function always returns 0,
647
+ if microscope is in imaging mode. In STEM mode this
648
+ function works reportedly nevertheless.
645
649
 
646
650
  .. versionadded:: 1.0.9
647
651
  """
@@ -651,7 +655,11 @@ class BaseMicroscope(ABC):
651
655
  def get_indicated_magnification(self):
652
656
  """
653
657
  Return (indicated) magnification in imaging modes.
654
- If microscope is in diffraction mode, 0 is returned.
658
+
659
+ .. note::
660
+ The scripting manual states, that this function always returns 0,
661
+ if microscope is in diffraction mode. In STEM mode this
662
+ function works reportedly nevertheless.
655
663
 
656
664
  .. note::
657
665
  On Titan 1.1 software this method returns 0.0 regardless of used mode. See :ref:`restrictions`.
@@ -0,0 +1 @@
1
+ __version__ = '2.1.0'
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: temscript
3
- Version: 2.0.1
3
+ Version: 2.1.0
4
4
  Summary: TEM Scripting adapter for FEI microscopes
5
5
  Home-page: https://github.com/niermann/temscript
6
6
  Author: Tore Niermann
@@ -21,6 +21,19 @@ Classifier: Operating System :: OS Independent
21
21
  Requires-Python: >=3.4
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
+ Requires-Dist: numpy
25
+ Dynamic: author
26
+ Dynamic: author-email
27
+ Dynamic: classifier
28
+ Dynamic: description
29
+ Dynamic: description-content-type
30
+ Dynamic: home-page
31
+ Dynamic: license
32
+ Dynamic: platform
33
+ Dynamic: project-url
34
+ Dynamic: requires-dist
35
+ Dynamic: requires-python
36
+ Dynamic: summary
24
37
 
25
38
  # About
26
39
 
@@ -1 +0,0 @@
1
- __version__ = '2.0.1'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes