-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
166 add functionality to upload log text report files to google drive #170
base: main
Are you sure you want to change the base?
166 add functionality to upload log text report files to google drive #170
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code runs as expected. The test also shows if the file is uploaded or not. You may consider checking if the folder_id actually exists before attempting to use it. Example: If folder_id do this else create folder_id. It's just a small check in case the folder doesn't exist, the code will have a way to verify that's the case or possible handle it. Otherwise, the code runs as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key.json | ||
backend/key.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don’t need to add this to prevent pushing the key.json
file, as it was already included in the .gitignore
on the line above.
@@ -1,4 +1,5 @@ | |||
from PythonClient.multirotor.storage.abstract.storage_service import StorageServiceInterface | |||
from abstract.storage_service import StorageServiceInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to use relative imports, you just need to use a single period (.)
, which refers to the current package.
@@ -18,6 +19,47 @@ def __init__(self, folder_id='1zZ06TaCzqdPJlQ9Uc4VgJaawBZm3eTSS'): | |||
""" | |||
SCOPES = ['https://www.googleapis.com/auth/drive'] | |||
self.credentials = service_account.Credentials.from_service_account_file( | |||
'key.json', scopes=SCOPES) | |||
'backend/key.json', scopes=SCOPES) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous implementation was already trying to find key.json
in the backend
directory. Your implementation causes an error: FileNotFoundError: [Errno 2] No such file or directory: 'backend/key.json'
.
#166
allows for automatic uploading of log files to Google Drive
this was added incase Google Cloud is unwanted/unavailable/ to allow for easier use of other storage devices
Built out from the previously created abstract storage service class, locks the thread during upload, creates the text file, the meta data for the upload, and uploads using the key.json.
Further, there is built-in testing if the gd_storage_service.py is ran as main.