@@ -44,6 +44,8 @@ def get_PYRO4BOT_HOME():
44
44
sys .path .append (PYRO4BOT_HOME )
45
45
from node .libs .myjson import MyJson
46
46
47
+ error = False
48
+
47
49
48
50
def check_args (args = None ):
49
51
""" It checks the arguments passed to the main program and returns them in a dictionary """
@@ -119,11 +121,21 @@ def __get_source_list():
119
121
def __search_in (collection , element ):
120
122
""" It searches an element in a collection of data dictionaries and returns the url path of the element back
121
123
This is used to searches the name of a component or a service in a collection of data sources of modules """
124
+ path = False
122
125
for (url , repo ) in collection :
123
- path = next ((description ['path' ] for name , description
124
- in [(k , v ) for k , v in
125
- [it for sublist in [elements .items () for module , elements in repo .items ()] for it in sublist ]]
126
- if element .lower == name .lower () or description ['content' ].lower () == element .lower ()), False )
126
+ for k , v in repo .items ():
127
+ for name , description in v .items ():
128
+ if element .lower () == name .lower () or element .lower () == description ['content' ].lower ():
129
+ path = description ['path' ]
130
+ break
131
+ if path :
132
+ break
133
+ # this code doesn't work in the RPI (py3.5) for elements like picam_socket (elemts w/ diff names than the file)
134
+ # path = next((description['path'] for name, description
135
+ # in [(k, v) for k, v in
136
+ # [it for sublist in [elements.items() for module, elements in repo.items()]
137
+ # for it in sublist]]
138
+ # if element.lower == name.lower() or description['content'].lower() == element.lower()), False)
127
139
if path :
128
140
return url , path
129
141
return False
@@ -143,6 +155,7 @@ def find_elements(json_module_classes, source_list, local_list, botname):
143
155
::return: list of each element with its url (repository url header, url_path specific location in the repository)
144
156
::rtype: list of [ tuple (repository: string, url_path: string) ] """
145
157
global configuration
158
+ global error
146
159
downloadable_elements = []
147
160
for element in json_module_classes :
148
161
print ("Searching the element: " , element )
@@ -158,6 +171,7 @@ def find_elements(json_module_classes, source_list, local_list, botname):
158
171
print ("Found in local: " , os .path .abspath (local_path ))
159
172
else :
160
173
print ("ERROR with the element: " , element , ".\t It's not found in the repository." )
174
+ error = True
161
175
print ("You should define it in the directories of your robot" )
162
176
163
177
return downloadable_elements
@@ -240,7 +254,9 @@ def create_robot(conf):
240
254
print ("The robot {} exists" .format (conf ["robot" ]))
241
255
return True
242
256
except :
257
+ global error
243
258
print ("ERROR: There has been an error with the files and folders of your robot" )
259
+ error = True
244
260
return False
245
261
246
262
@@ -263,9 +279,15 @@ def create_robot(conf):
263
279
if create_robot (args ):
264
280
if args ['update' ]:
265
281
update_robot (args )
266
- print ("Completed." )
282
+ if error :
283
+ print ("Some error have occur." )
284
+ else :
285
+ print ("Completed." )
267
286
else :
268
- print ("Completed" )
287
+ if error :
288
+ print ("Some error have occur." )
289
+ else :
290
+ print ("Completed." )
269
291
else :
270
292
if args ['update' ]:
271
293
print ("You cannot update the robot because it still doesn't exist." )
0 commit comments