-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added untested code for firmware update for #2
- Loading branch information
Showing
2 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,24 @@ | ||
|
||
import os | ||
from typing import BinaryIO | ||
from huawei_lte_api.ApiGroup import ApiGroup | ||
|
||
|
||
class FileManager(ApiGroup): | ||
def upload(self, uploadfile: str): | ||
return self._connection.post('filemanager/upload', { | ||
'uploadfile': uploadfile | ||
}) # !FIXME see issue #2 | ||
def upload(self, uploadfile: BinaryIO, uploadfile_name: str) -> str: | ||
""" | ||
Uploads firmware update and triggers it | ||
:param uploadfile: filehandle on file to upload | ||
:param uploadfile_name: name of uploaded file | ||
:return: str | ||
""" | ||
uploadfile_basename = os.path.basename(uploadfile_name) | ||
filename, extension = os.path.splitext(uploadfile_basename) | ||
|
||
if extension not in ['bin', 'zip']: | ||
raise Exception('Only *.bin or *.zip is allowed') | ||
|
||
return self._connection.post_file('filemanager/upload', { | ||
'uploadfile': uploadfile, | ||
}, { | ||
'cur_path': 'OU:{}'.format(uploadfile_basename) | ||
}) |