Skip to content

Commit 9c2c89a

Browse files
Merge pull request #390 from the-snowwhite/py-fixes
Py fixes
2 parents 6238a0c + 5c0f52a commit 9c2c89a

17 files changed

Lines changed: 48 additions & 32 deletions

File tree

src/executables/mklauncher/src/mklauncher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from operator import attrgetter
1919

2020
from machinekit.hal import service
21-
from machinekit.hal import config
21+
#from machinekit.hal import config
2222

2323
from google.protobuf.message import DecodeError
2424
from machinetalk.protobuf.message_pb2 import Container
@@ -637,10 +637,10 @@ def main():
637637
else:
638638
logger.setLevel(logging.INFO)
639639

640-
mkconfig = config.Config()
640+
#mkconfig = config.Config()
641641
mkini = os.getenv("MACHINEKIT_INI")
642642
if mkini is None:
643-
mkini = mkconfig.MACHINEKIT_INI
643+
mkini = machinekit_hal_ini_file
644644
if not os.path.isfile(mkini):
645645
sys.stderr.write("MACHINEKIT_INI " + mkini + " does not exist\n")
646646
sys.exit(1)

src/libraries/config_service/src/configserver.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import argparse
1010
from six.moves import configparser
1111

12-
from machinekit import service
13-
from machinekit import config
12+
from machinekit.hal.service import service
13+
#from machinekit import config
1414

1515
from google.protobuf.message import DecodeError
1616
from machinetalk.protobuf.message_pb2 import Container
@@ -252,10 +252,10 @@ def main():
252252

253253
debug = args.debug
254254

255-
mkconfig = config.Config()
255+
#mkconfig = config.Config()
256256
mkini = os.getenv("MACHINEKIT_INI")
257257
if mkini is None:
258-
mkini = mkconfig.MACHINEKIT_INI
258+
mkini = machinekit_hal_ini_file
259259
if not os.path.isfile(mkini):
260260
sys.stderr.write("MACHINEKIT_INI " + mkini + " does not exist\n")
261261
sys.exit(1)

src/libraries/cyhal/examples/component.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
import time
12-
import machinekit.hal.cyhal as hal
12+
import machinekit.hal.pyhal as hal
1313

1414
c = hal.Component('zzz')
1515
p = c.newpin("p0", hal.HAL_S32, hal.HAL_OUT, init=42)

src/libraries/cyhal/examples/group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# basic group example
33

4-
import machinekit.hal.cyhal as hal
4+
import machinekit.hal.pyhal as hal
55
g2 = hal.Group("group1")
66
s1 = hal.Signal("sigs32", hal.HAL_S32)
77
s2 = hal.Signal("sigfloat", hal.HAL_FLOAT)

src/libraries/cyhal/examples/heaptrace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# HAL internals introspection - the hal_data descriptor
55
# and shared memory heap
66

7-
import machinekit.hal.cyhal as hal
7+
import machinekit.hal.pyhal as hal
88

99
hd = hal.HALData()
1010
hd.heap_flags = -1 # log RTAPI malloc/free operations

src/libraries/cyhal/examples/internal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# HAL internals introspection - the hal_data descriptor
55
# and shared memory heap
66

7-
import machinekit.hal.cyhal as hal
7+
import machinekit.hal.pyhal as hal
88

99
hd = hal.HALData()
1010
hd.heap_flags = -1 # log RTAPI malloc/free operations

src/libraries/cyhal/examples/test_instance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
import machinekit.hal.cyhal as hal
3+
import machinekit.hal.pyhal as hal
44

55

66
for name in hal.instances():

src/libraries/cyruntime/src/rtapi.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
# RTAPI python bindings
2+
"""# RTAPI python bindings
33
# shared memory
44
# RT logger
55
# rtapi_app command interface
6-
6+
"""
77
from rtapi cimport *
88

99
from os import strerror, getpid
@@ -145,6 +145,7 @@ CS_NOT_LOADED = 0
145145
CS_NOT_RT = 1
146146
CS_RTLOADED_NOT_INSTANTIABLE = 2
147147
CS_RTLOADED_AND_INSTANTIABLE = 3
148+
""" enums for classify_comp """
148149

149150
autoload = True # autoload components on newinst
150151

@@ -158,6 +159,7 @@ def classify_comp(comp):
158159
if not c.has_ctor:
159160
return CS_RTLOADED_NOT_INSTANTIABLE
160161
return CS_RTLOADED_AND_INSTANTIABLE
162+
""" classifies a component for newinst"""
161163

162164

163165
class RTAPIcommand:

src/libraries/hal_glib/src/hal_glib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def is_pin(self):
137137

138138
def enum(*sequential, **named):
139139
enums = dict(zip(sequential, range(len(sequential))), **named)
140-
reverse = dict((value, key) for key, value in enums.iteritems())
140+
reverse = dict((value, key) for key, value in enums.items())
141141
enums['reverse_mapping'] = reverse
142142
return type('Enum', (), enums)
143143

@@ -226,7 +226,7 @@ def __init__(self,
226226

227227
def start(self):
228228
# start resolution for the missing URI's
229-
for key, uri in self.services.iteritems():
229+
for key, uri in self.services.items():
230230
if not uri:
231231
if self.remote:
232232
if not self.sda:
@@ -407,7 +407,7 @@ def bind(self):
407407
self.tx.type = MT_HALRCOMP_BIND
408408
c = self.tx.comp.add()
409409
c.name = self.name
410-
for pin_name,pin in self.pinsbyname.iteritems():
410+
for pin_name,pin in self.pinsbyname.items():
411411
p = c.pin.add()
412412
p.name = self.name + "." + pin_name
413413
p.type = pin.get_type()

src/libraries/launcher/src/launcher.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
2+
"""# Launcher python bindings
3+
# launch and stop processes
4+
"""
15
import os
26
import shlex
37
import sys
48
from time import *
59
import subprocess
610
import signal
7-
from machinekit.hal import compat
11+
from machinekit.hal.cycompat import compat
812

913
_processes = []
1014
_realtime_started = False
@@ -16,6 +20,7 @@ def end_session():
1620
stop_processes()
1721
if _realtime_started: # Stop realtime only when explicitly started
1822
stop_realtime()
23+
"""# ends a running Machinekit session"""
1924

2025

2126
# checks wheter a single command is available or not
@@ -25,13 +30,15 @@ def check_command(command):
2530
if process.returncode != 0:
2631
print(command + ' not found, check Machinekit installation')
2732
sys.exit(1)
33+
"""# checks wheter a single command is available or not"""
2834

2935

3036
# checks the whole Machinekit installation
3137
def check_installation():
3238
commands = ['realtime', 'configserver', 'halcmd', 'haltalk']
3339
for command in commands:
3440
check_command(command)
41+
"""# checks the whole Machinekit installation"""
3542

3643

3744
# checks for a running session and cleans it up if necessary
@@ -56,6 +63,7 @@ def cleanup_session():
5663
except OSError:
5764
pass
5865
sys.stdout.write('done\n')
66+
"""# checks for a running session and cleans it up if necessary"""
5967

6068

6169
# starts a command, waits for termination and checks the output
@@ -64,6 +72,7 @@ def check_process(command):
6472
sys.stdout.flush()
6573
subprocess.check_call(command, shell=True)
6674
sys.stdout.write('done\n')
75+
"""# starts a command, waits for termination and checks the output"""
6776

6877

6978
# starts and registers a process
@@ -79,6 +88,7 @@ def start_process(command, check=True, wait=1.0):
7988
raise subprocess.CalledProcessError(process.returncode, command, None)
8089
_processes.append(process)
8190
sys.stdout.write('done\n')
91+
"""# starts and registers a process"""
8292

8393

8494
# stops a registered process by its name
@@ -91,6 +101,7 @@ def stop_process(command):
91101
os.killpg(process.pid, signal.SIGTERM)
92102
process.wait()
93103
sys.stdout.write('done\n')
104+
"""# stops a registered process by its name"""
94105

95106

96107
# stops all registered processes
@@ -101,6 +112,7 @@ def stop_processes():
101112
os.killpg(process.pid, signal.SIGTERM)
102113
process.wait()
103114
sys.stdout.write('done\n')
115+
"""# stops all registered processes"""
104116

105117

106118
# loads a HAL configuration file
@@ -110,14 +122,15 @@ def load_hal_file(filename, ini=None):
110122

111123
_, ext = os.path.splitext(filename)
112124
if ext == '.py':
113-
from machinekit import rtapi
125+
from machinekit.hal.cyruntime import rtapi
114126

115127
if not rtapi.__rtapicmd:
116128
rtapi.init_RTAPI()
117129
if ini is not None:
118-
from machinekit import config
130+
#from machinekit import config
119131

120-
config.load_ini(ini)
132+
#config.load_ini(ini)
133+
ini = machinekit_hal_ini_file
121134
with open(filename, 'r') as f:
122135
data = compile(f.read(), filename, 'exec')
123136
globals_ = {}
@@ -260,6 +273,7 @@ def _exit_handler(signum, frame):
260273
# set the Machinekit debug level
261274
def set_debug_level(level):
262275
os.environ['DEBUG'] = str(level)
276+
"""# set the Machinekit debug level"""
263277

264278

265279
# set the Machinekit ini

0 commit comments

Comments
 (0)