forked from CLCMacTeam/besapi
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add upload files example, improve upload function
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
Upload files in folder. | ||
requires `besapi`, install with command `pip install besapi` | ||
""" | ||
|
||
import os | ||
|
||
import besapi | ||
|
||
|
||
def main(path_folder="./tmp"): | ||
"""Execution starts here""" | ||
print("main()") | ||
bes_conn = besapi.besapi.get_bes_conn_using_config_file() | ||
bes_conn.login() | ||
|
||
print(f"INFO: Uploading new files within: {os.path.abspath(path_folder)}") | ||
|
||
for entry in os.scandir(path_folder): | ||
if entry.is_file() and "README.md" not in entry.path: | ||
if " " in os.path.basename(entry.path): | ||
print(f"ERROR: files cannot contain spaces! skipping: {entry.path}") | ||
continue | ||
print(f"Processing: {entry.path}") | ||
output = bes_conn.upload(entry.path) | ||
# print(output) | ||
print(bes_conn.parse_upload_result_to_prefetch(output)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main("./examples/upload_files") |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
put files in this folder to have them be uploaded to the root server by the script upload_files.py |
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