pyconstrobe 0.1__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2024] [Joseph Louis]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.2
2
+ Name: pyconstrobe
3
+ Version: 0.1
4
+ Summary: This package is used to automate the DES application ConStrobe.
5
+ Author: Joseph Louis
6
+ Author-email: joseph.louis@oregonstate.edu
7
+ Requires-Python: >=3.6
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Dynamic: author
11
+ Dynamic: author-email
12
+ Dynamic: description
13
+ Dynamic: description-content-type
14
+ Dynamic: requires-python
15
+ Dynamic: summary
16
+
17
+ This package works when jStrobe is installed at c:/Program Files/jStrobe/jStrobe/jStrobe.exe
18
+
19
+ Download example files from https://github.com/jlouis2k4/TestPythonJS
20
+
21
+
@@ -0,0 +1,5 @@
1
+ This package works when jStrobe is installed at c:/Program Files/jStrobe/jStrobe/jStrobe.exe
2
+
3
+ Download example files from https://github.com/jlouis2k4/TestPythonJS
4
+
5
+
@@ -0,0 +1,6 @@
1
+ # Importing the ProcessManager class for easy access
2
+ from .process_manager import ProcessManager
3
+
4
+ # You can add any other initializations or imports here
5
+ __version__ = "0.1.0"
6
+ __all__ = ['ProcessManager']
@@ -0,0 +1,67 @@
1
+ import subprocess
2
+ import threading
3
+ import os
4
+
5
+
6
+
7
+ class ProcessManager:
8
+ def __init__(self, callback=None):
9
+ build_mode = os.getenv('BUILD_MODE', 'Release') # Default to 'release' if not set
10
+ print(build_mode)
11
+ if build_mode=='Debug':
12
+ path_to_exe = r"C:\source\constrobe\csApp\Debug\constrobe.exe"
13
+ else:
14
+ path_to_exe = r"C:\Program Files\constrobe\constrobe\constrobe.exe"
15
+
16
+
17
+
18
+ self.process = subprocess.Popen(
19
+ [path_to_exe, '--from-python'],
20
+ stdin=subprocess.PIPE,
21
+ stdout=subprocess.PIPE,
22
+ stderr=subprocess.PIPE,
23
+ text=True,
24
+ creationflags=subprocess.CREATE_NEW_CONSOLE
25
+ )
26
+ self.callback = callback # Custom callback for processing messages
27
+ self.keep_reading = True # Flag to control the reading loop
28
+ self.reader_thread = threading.Thread(target=self.read_messages)
29
+ self.reader_thread.daemon = True # Allow thread to exit when main program exits
30
+ self.reader_thread.start()
31
+
32
+ def write_message(self, message):
33
+ """Write a message to the process's stdin."""
34
+ self.process.stdin.write(message + "\n")
35
+ self.process.stdin.flush()
36
+
37
+ def read_messages(self):
38
+ """Read messages from the process's stdout."""
39
+ while self.keep_reading:
40
+ response = self.process.stdout.readline().strip()
41
+ if response:
42
+ if response == "COMPLETE":
43
+ print("Process completed.")
44
+ self.keep_reading = False # Stop reading messages
45
+ break
46
+ if self.callback:
47
+ response_message = self.callback(response)
48
+ if response_message:
49
+ self.write_message(response_message)
50
+
51
+ def cleanup(self):
52
+ """Clean up the process and close streams."""
53
+ print("Cleaning up resources...")
54
+ self.keep_reading = False # Signal the thread to stop reading
55
+ self.running = False
56
+ self.reader_thread.join() # Wait for the thread to finish
57
+ self.process.stdin.close()
58
+ self.process.stdout.close()
59
+ self.process.stderr.close()
60
+ if self.process:
61
+ self.process.terminate() # Try to terminate the process gracefully
62
+ try:
63
+ return self.process.wait(timeout=5) # Wait up to 5 seconds for it to finish
64
+ except subprocess.TimeoutExpired:
65
+ print("Process did not terminate, force killing it...")
66
+ self.process.kill() # Force kill the process if it doesn't terminate in time
67
+ return self.process.wait() # Ensure it finishes
@@ -0,0 +1,6 @@
1
+ # Importing the ProcessManager class for easy access
2
+ from .process_manager import ProcessManager
3
+
4
+ # You can add any other initializations or imports here
5
+ __version__ = "0.1.0"
6
+ __all__ = ['ProcessManager']
@@ -0,0 +1,67 @@
1
+ import subprocess
2
+ import threading
3
+ import os
4
+
5
+
6
+
7
+ class ProcessManager:
8
+ def __init__(self, callback=None):
9
+ build_mode = os.getenv('BUILD_MODE', 'Release') # Default to 'release' if not set
10
+ print(build_mode)
11
+ if build_mode=='Debug':
12
+ path_to_exe = r"C:\source\constrobe\csApp\Debug\constrobe.exe"
13
+ else:
14
+ path_to_exe = r"C:\Program Files\constrobe\constrobe\constrobe.exe"
15
+
16
+
17
+
18
+ self.process = subprocess.Popen(
19
+ [path_to_exe, '--from-python'],
20
+ stdin=subprocess.PIPE,
21
+ stdout=subprocess.PIPE,
22
+ stderr=subprocess.PIPE,
23
+ text=True,
24
+ creationflags=subprocess.CREATE_NEW_CONSOLE
25
+ )
26
+ self.callback = callback # Custom callback for processing messages
27
+ self.keep_reading = True # Flag to control the reading loop
28
+ self.reader_thread = threading.Thread(target=self.read_messages)
29
+ self.reader_thread.daemon = True # Allow thread to exit when main program exits
30
+ self.reader_thread.start()
31
+
32
+ def write_message(self, message):
33
+ """Write a message to the process's stdin."""
34
+ self.process.stdin.write(message + "\n")
35
+ self.process.stdin.flush()
36
+
37
+ def read_messages(self):
38
+ """Read messages from the process's stdout."""
39
+ while self.keep_reading:
40
+ response = self.process.stdout.readline().strip()
41
+ if response:
42
+ if response == "COMPLETE":
43
+ print("Process completed.")
44
+ self.keep_reading = False # Stop reading messages
45
+ break
46
+ if self.callback:
47
+ response_message = self.callback(response)
48
+ if response_message:
49
+ self.write_message(response_message)
50
+
51
+ def cleanup(self):
52
+ """Clean up the process and close streams."""
53
+ print("Cleaning up resources...")
54
+ self.keep_reading = False # Signal the thread to stop reading
55
+ self.running = False
56
+ self.reader_thread.join() # Wait for the thread to finish
57
+ self.process.stdin.close()
58
+ self.process.stdout.close()
59
+ self.process.stderr.close()
60
+ if self.process:
61
+ self.process.terminate() # Try to terminate the process gracefully
62
+ try:
63
+ return self.process.wait(timeout=5) # Wait up to 5 seconds for it to finish
64
+ except subprocess.TimeoutExpired:
65
+ print("Process did not terminate, force killing it...")
66
+ self.process.kill() # Force kill the process if it doesn't terminate in time
67
+ return self.process.wait() # Ensure it finishes
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.2
2
+ Name: pyconstrobe
3
+ Version: 0.1
4
+ Summary: This package is used to automate the DES application ConStrobe.
5
+ Author: Joseph Louis
6
+ Author-email: joseph.louis@oregonstate.edu
7
+ Requires-Python: >=3.6
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Dynamic: author
11
+ Dynamic: author-email
12
+ Dynamic: description
13
+ Dynamic: description-content-type
14
+ Dynamic: requires-python
15
+ Dynamic: summary
16
+
17
+ This package works when jStrobe is installed at c:/Program Files/jStrobe/jStrobe/jStrobe.exe
18
+
19
+ Download example files from https://github.com/jlouis2k4/TestPythonJS
20
+
21
+
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ csPy/__init__.py
5
+ csPy/process_manager.py
6
+ pyconstrobe/__init__.py
7
+ pyconstrobe/process_manager.py
8
+ pyconstrobe.egg-info/PKG-INFO
9
+ pyconstrobe.egg-info/SOURCES.txt
10
+ pyconstrobe.egg-info/dependency_links.txt
11
+ pyconstrobe.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ csPy
2
+ pyconstrobe
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,13 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="pyconstrobe", # Replace with your package name
5
+ version="0.1", # Version number
6
+ packages=find_packages(), # Automatically find and include all packages
7
+ author="Joseph Louis",
8
+ author_email="joseph.louis@oregonstate.edu",
9
+ description="This package is used to automate the DES application ConStrobe.",
10
+ long_description=open('README.md').read(),
11
+ long_description_content_type="text/markdown",
12
+ python_requires='>=3.6', # Specify minimum Python version (optional)
13
+ )