43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import os, subprocess, time, traceback
|
||
|
||
print('开始马达')
|
||
try:
|
||
# D:\software\Anaconda3\envs\py27_32\
|
||
python2_command = r'python2.exe ' + os.path.dirname(__file__) + '/ArcusDevice.py' + ' CLR PX=0 EO=1 J+'
|
||
print(python2_command)
|
||
print(python2_command.split())
|
||
process = subprocess.Popen(python2_command.split(), stdout=subprocess.PIPE)
|
||
try:
|
||
output, error = process.communicate(timeout=1)
|
||
except subprocess.TimeoutExpired:
|
||
print('有错1')
|
||
process.kill()
|
||
output, error = process.communicate()
|
||
except:
|
||
traceback.print_exc()
|
||
print('有错2')
|
||
pass
|
||
|
||
|
||
print('转动5秒')
|
||
time.sleep(5)
|
||
|
||
|
||
print('返回马达')
|
||
try:
|
||
# D:\software\Anaconda3\envs\py27_32\
|
||
# 打包:https://stackoverflow.com/questions/58995937/using-pyinstaller-to-convert-python3-and-python2-to-exe
|
||
python2_command = r'python2.exe ' + os.path.dirname(__file__) + '/ArcusDevice.py' + ' CLR STOP X0'
|
||
print(python2_command)
|
||
process = subprocess.Popen(python2_command.split(), stdout=subprocess.PIPE)
|
||
try:
|
||
output, error = process.communicate(timeout=1)
|
||
except subprocess.TimeoutExpired:
|
||
print('有错3')
|
||
process.kill()
|
||
output, error = process.communicate()
|
||
except:
|
||
traceback.print_exc()
|
||
print('有错4')
|
||
pass
|