-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLibraryDownloader.py
42 lines (30 loc) · 1.14 KB
/
LibraryDownloader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from utils import executeCli
def searchLibrary(searchTerm:str) -> str:
"""
for searching libraries using arduino-cli
:param searchTerm: string that typed to front-end. will be search using arduino-cli
:type searchTerm: str
:return: returns string but in json format, will be converted to json on front-end
:rtype: str
"""
executeCli(f"lib update-index")
result = executeCli(f"lib search {searchTerm} --format json")
return result
def installLibrary(name:str, version:str) -> str:
"""
:param name: full name of the library
:type name: str
:param version: version of the library, like 1.3.4
:type version: str
:return: returns subprocess output which is result of arduino-cli execution
:rtype: str
"""
result = executeCli(f"lib install \"{name}\"@{version}")
return result
def installLibraryZip(zipPath:str) -> str:
"""
That function will take path of .zip file and install library using arduino-cli.
.zip file will be dropped or selected from front-end, path will be passed this function through Websocket
"""
raise NotImplemented
#TODO install from zip