Skip to content

Commit 1bacbe5

Browse files
committed
Add __init__ function
1 parent 0514983 commit 1bacbe5

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/RobotOS.jl

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
module RobotOS
22

33
using PyCall
4-
const __rospy__ = try
5-
pyimport("rospy")
6-
catch ex
7-
if (isa(ex, PyCall.PyError) &&
8-
pycall(pybuiltin("str"), PyAny, ex.val) == "No module named rospy")
9-
error("rospy not found!\nHas an environment setup script been run?")
10-
else
11-
rethrow(ex)
4+
5+
function __init__()
6+
#Put julia's ARGS into python's so remappings will work
7+
global const __sys__ = pyimport("sys")
8+
__sys__["argv"] = ARGS
9+
10+
global const __rospy__ = try
11+
pyimport("rospy")
12+
catch ex
13+
if (isa(ex, PyCall.PyError) &&
14+
pycall(pybuiltin("str"), PyAny, ex.val) == "No module named rospy")
15+
error("rospy not found!\nHas an environment setup script been run?")
16+
else
17+
rethrow(ex)
18+
end
1219
end
1320
end
1421

15-
#Put julia's ARGS into python's so remappings will work
16-
py_sys = pyimport("sys")
17-
py_sys["argv"] = ARGS
18-
1922
include("debug.jl")
2023
include("time.jl")
2124
include("gentypes.jl")

0 commit comments

Comments
 (0)