Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nanospace-python-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nanostar
nanospace
nanospace-clients
nanospace-python-client
Commits
4c59c9b2
Commit
4c59c9b2
authored
Aug 22, 2019
by
lucien senaneuch
Committed by
GATEAU Thibault
Dec 19, 2022
Browse files
Options
Downloads
Patches
Plain Diff
[Add verify=False] Problem with ssl certification, force it to false
parent
ad00c538
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
nanospace.py
+12
-12
12 additions, 12 deletions
nanospace.py
simple_example.py
+15
-14
15 additions, 14 deletions
simple_example.py
with
27 additions
and
26 deletions
nanospace.py
+
12
−
12
View file @
4c59c9b2
...
...
@@ -15,7 +15,7 @@ class Nanospace:
nanospace.password =
'
test
'
nanospace.login()
"""
r
=
rq
.
post
(
self
.
ApiBaseAddress
+
'
login
'
,
json
=
{
"
username
"
:
self
.
username
,
"
password
"
:
self
.
password
})
r
=
rq
.
post
(
self
.
ApiBaseAddress
+
'
login
'
,
json
=
{
"
username
"
:
self
.
username
,
"
password
"
:
self
.
password
}
,
verify
=
False
)
if
r
.
status_code
>=
200
and
r
.
status_code
<
300
:
return
r
.
headers
.
get
(
'
Authorization
'
)
else
:
...
...
@@ -45,7 +45,7 @@ class Nanospace:
print(nanospace.get_value(89))
1.53
"""
r
=
rq
.
get
(
self
.
ApiBaseAddress
+
'
value/
'
+
str
(
id
),
headers
=
self
.
headers
)
r
=
rq
.
get
(
self
.
ApiBaseAddress
+
'
value/
'
+
str
(
id
),
headers
=
self
.
headers
,
verify
=
False
)
r_data
=
r
.
json
()
if
r
.
status_code
>=
200
and
r
.
status_code
<
300
:
return
r_data
[
'
value
'
]
...
...
@@ -60,7 +60,7 @@ class Nanospace:
:Exemple:
nanospace.update_value(89,
'
altitude
'
,
'
km
'
, 8000)
"""
r
=
rq
.
put
(
self
.
ApiBaseAddress
+
'
value/
'
+
str
(
id
),
json
=
{
'
name
'
:
name
,
'
value
'
:
value
},
headers
=
self
.
headers
)
r
=
rq
.
put
(
self
.
ApiBaseAddress
+
'
value/
'
+
str
(
id
),
json
=
{
'
name
'
:
name
,
'
value
'
:
value
},
headers
=
self
.
headers
,
verify
=
False
)
r_data
=
r
.
json
()
if
r
.
status_code
<
200
or
r
.
status_code
>=
300
:
raise
ValueError
(
r_data
)
...
...
@@ -77,7 +77,7 @@ class Nanospace:
print(nanospace.get_value(92))
Get(78) + 5
"""
r
=
rq
.
get
(
self
.
ApiBaseAddress
+
'
formula/
'
+
str
(
id
),
headers
=
self
.
headers
)
r
=
rq
.
get
(
self
.
ApiBaseAddress
+
'
formula/
'
+
str
(
id
),
headers
=
self
.
headers
,
verify
=
False
)
r_data
=
r
.
json
()
if
r
.
status_code
>=
200
and
r
.
status_code
<
300
:
return
r_data
[
'
formula
'
]
...
...
@@ -92,7 +92,7 @@ class Nanospace:
:Exemple:
nanospace.update_value(92,
'
multiplication
'
,
'
5*3
'
)
"""
r
=
rq
.
put
(
self
.
ApiBaseAddress
+
'
formula/
'
+
str
(
id
),
json
=
{
'
name
'
:
name
,
'
formula
'
:
value
},
headers
=
self
.
headers
)
r
=
rq
.
put
(
self
.
ApiBaseAddress
+
'
formula/
'
+
str
(
id
),
json
=
{
'
name
'
:
name
,
'
formula
'
:
value
},
headers
=
self
.
headers
,
verify
=
False
)
r_data
=
r
.
json
()
if
r
.
status_code
<
200
or
r
.
status_code
>=
300
:
raise
ValueError
(
r_data
)
...
...
@@ -109,7 +109,7 @@ class Nanospace:
:Exemple:
nanospace._create_component(89,
'
mySuperComponent
'
)
"""
r
=
rq
.
post
(
self
.
ApiBaseAddress
+
'
component?parentId=
'
+
str
(
idParent
),
json
=
{
'
name
'
:
componentName
},
headers
=
self
.
headers
)
r
=
rq
.
post
(
self
.
ApiBaseAddress
+
'
component?parentId=
'
+
str
(
idParent
),
json
=
{
'
name
'
:
componentName
},
headers
=
self
.
headers
,
verify
=
False
)
r_data
=
r
.
json
()
if
r
.
status_code
<
200
or
r
.
status_code
>=
300
:
raise
ValueError
(
r_data
)
...
...
@@ -125,7 +125,7 @@ class Nanospace:
nanospace._create_mode(28,
'
test-mode
'
)
"""
r
=
rq
.
post
(
self
.
ApiBaseAddress
+
'
mode?parentId=
'
+
str
(
idParent
),
json
=
{
'
name
'
:
modeName
},
headers
=
self
.
headers
)
r
=
rq
.
post
(
self
.
ApiBaseAddress
+
'
mode?parentId=
'
+
str
(
idParent
),
json
=
{
'
name
'
:
modeName
},
headers
=
self
.
headers
,
verify
=
False
)
r_data
=
r
.
json
()
if
r
.
status_code
<
200
or
r
.
status_code
>=
300
:
raise
ValueError
(
r_data
)
...
...
@@ -140,7 +140,7 @@ class Nanospace:
:Exemple:
nanospace._create_string_value(28,
'
string_value
'
,
'
Hello-World
'
)
"""
r
=
rq
.
post
(
self
.
ApiBaseAddress
+
'
string?parentId=
'
+
str
(
idParent
),
json
=
{
'
name
'
:
valueName
,
'
value
'
:
value
,
'
type
'
:
'
string_value
'
},
headers
=
self
.
headers
)
r
=
rq
.
post
(
self
.
ApiBaseAddress
+
'
string?parentId=
'
+
str
(
idParent
),
json
=
{
'
name
'
:
valueName
,
'
value
'
:
value
,
'
type
'
:
'
string_value
'
},
headers
=
self
.
headers
,
verify
=
False
)
r_data
=
r
.
json
()
if
r
.
status_code
<
200
or
r
.
status_code
>=
300
:
raise
ValueError
(
r_data
)
...
...
@@ -155,7 +155,7 @@ class Nanospace:
:Exemple:
nanospace._create_formula_value(28,
'
value
'
,
'
5*8
'
)
"""
r
=
rq
.
post
(
self
.
ApiBaseAddress
+
'
formula?parentId=
'
+
str
(
idParent
),
json
=
{
'
name
'
:
valueName
,
'
formula
'
:
value
,
'
type
'
:
'
string_value
'
},
headers
=
self
.
headers
)
r
=
rq
.
post
(
self
.
ApiBaseAddress
+
'
formula?parentId=
'
+
str
(
idParent
),
json
=
{
'
name
'
:
valueName
,
'
formula
'
:
value
,
'
type
'
:
'
string_value
'
},
headers
=
self
.
headers
,
,
verify
=
False
)
r_data
=
r
.
json
()
if
r
.
status_code
<
200
or
r
.
status_code
>=
300
:
raise
ValueError
(
r_data
)
...
...
@@ -170,7 +170,7 @@ class Nanospace:
:Exemple:
nanospace._delete_value(28)
"""
r
=
rq
.
delete
(
self
.
ApiBaseAddress
+
'
value/
'
+
str
(
idValue
),
headers
=
self
.
headers
)
r
=
rq
.
delete
(
self
.
ApiBaseAddress
+
'
value/
'
+
str
(
idValue
),
headers
=
self
.
headers
,
verify
=
False
)
# r_data = r.json()
# if r.status_code < 200 or r.status_code >= 300:
# raise ValueError(r_data)
...
...
@@ -185,7 +185,7 @@ class Nanospace:
:Exemple:
nanospace._delete_mode(28)
"""
r
=
rq
.
delete
(
self
.
ApiBaseAddress
+
'
mode/
'
+
str
(
idMode
),
headers
=
self
.
headers
)
r
=
rq
.
delete
(
self
.
ApiBaseAddress
+
'
mode/
'
+
str
(
idMode
),
headers
=
self
.
headers
,
verify
=
False
)
# r_data = r.json()
# if r.status_code < 200 or r.status_code >= 300:
# raise ValueError(r_data)
...
...
@@ -200,7 +200,7 @@ class Nanospace:
:Exemple:
nanospace._delete_component(28)
"""
r
=
rq
.
delete
(
self
.
ApiBaseAddress
+
'
component/
'
+
str
(
idComponent
),
headers
=
self
.
headers
)
r
=
rq
.
delete
(
self
.
ApiBaseAddress
+
'
component/
'
+
str
(
idComponent
),
headers
=
self
.
headers
,
verify
=
False
)
# r_data = r.json()
# if r.status_code < 200 or r.status_code >= 300:
# raise ValueError(r_data)
...
...
This diff is collapsed.
Click to expand it.
simple_example.py
+
15
−
14
View file @
4c59c9b2
from
nanospace
import
Nanospace
usr
=
'
usrLogin
'
pw
=
'
usrPw
'
srvAddr
=
'
yourSrvUrl
/
'
usr
=
'
test
'
pw
=
'
test
'
srvAddr
=
'
https://dcas-nanostar.isae.fr/api
/
'
nanospace
=
Nanospace
(
srvAddr
,
usr
,
pw
)
print
(
nanospace
.
get_string_value
(
83
))
nanospace
.
update__string_value
(
83
,
'
test
'
,
'
1Kg5
'
)
print
(
nanospace
.
get_formula_value
(
84
))
nanospace
.
update_formula_value
(
84
,
'
multiplication
'
,
'
5*20
'
)
nanospace
.
_create_component
(
40
,
'
newComponent
'
)
nanospace
.
_create_formula_value
(
231
,
'
test2
'
,
'
5*5
'
)
nanospace
.
_create_string_value
(
231
,
'
test3
'
,
'
Hello-world
'
)
nanospace
.
_create_mode
(
60
,
'
new_mode
'
)
nanospace
.
_delete_component
(
60
)
nanospace
.
_delete_value
(
102
)
nanospace
.
_delete_mode
(
231
)
\ No newline at end of file
# print(nanospace.get_string_value(1062))
# nanospace.update__string_value(83, 'test', '1Kg5')
# print(nanospace.get_formula_value(84))
# nanospace.update_formula_value(84, 'multiplication','5*20')
# nanospace._create_component(40, 'newComponent')
# nanospace._create_formula_value(231, 'test2', '5*5')
# nanospace._create_string_value(231, 'test3', 'Hello-world')
# nanospace._create_mode(60, 'new_mode')
# nanospace._delete_component(60)
# nanospace._delete_value(102)
# nanospace._delete_mode(231)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment