Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92976168
savesettings.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Nov 25, 07:24
Size
873 B
Mime Type
text/x-python
Expires
Wed, Nov 27, 07:24 (2 d)
Engine
blob
Format
Raw Data
Handle
22549393
Attached To
rSERVICENOWCHATALERT servicenow-chat-alert
savesettings.py
View Options
#!/usr/bin/python
# -*- coding: utf-8 -*-
import
os
,
sys
# add ../../Sources to the PYTHONPATH
sys
.
path
.
append
(
os
.
path
.
join
(
".."
,
".."
,
"Sources"
))
from
yocto_api
import
*
def
usage
():
sys
.
exit
(
"usage: demo <serial or logical name> <new logical name>"
)
if
len
(
sys
.
argv
)
!=
3
:
usage
()
errmsg
=
YRefParam
()
if
YAPI
.
RegisterHub
(
"usb"
,
errmsg
)
!=
YAPI
.
SUCCESS
:
sys
.
exit
(
"RegisterHub error: "
+
str
(
errmsg
))
m
=
YModule
.
FindModule
(
sys
.
argv
[
1
])
# use serial or logical name
if
m
.
isOnline
():
newname
=
sys
.
argv
[
2
]
if
not
YAPI
.
CheckLogicalName
(
newname
):
sys
.
exit
(
"Invalid name ("
+
newname
+
")"
)
m
.
set_logicalName
(
newname
)
m
.
saveToFlash
()
# do not forget this
print
(
"Module: serial= "
+
m
.
get_serialNumber
()
+
" / name= "
+
m
.
get_logicalName
())
else
:
sys
.
exit
(
"not connected (check identification and USB cable"
)
YAPI
.
FreeAPI
()
Event Timeline
Log In to Comment