[DEV/Tip/Google.Drive] Using google drive as a cloud plugin.

Post Python examples to help other users.
User avatar
Sam
Senior Member
Posts: 160
Joined: Tue Jul 03, 2018 3:00 pm
Location: Russian Federation
Contact:

[DEV/Tip/Google.Drive] Using google drive as a cloud plugin.

Postby Sam » Mon Jun 22, 2020 11:05 am

̶1̶.̶ ̶I̶n̶s̶t̶a̶l̶l̶ ̶`̶r̶e̶q̶u̶e̶s̶t̶s̶`̶ ̶t̶o̶ ̶S̶o̶u̶r̶c̶e̶.̶P̶y̶t̶h̶o̶n̶ ̶(̶p̶i̶p̶ ̶i̶n̶s̶t̶a̶l̶l̶ ̶r̶e̶q̶u̶e̶s̶t̶s̶ ̶-̶t̶ ̶<̶p̶a̶t̶h̶_̶t̶o̶_̶s̶i̶t̶e̶_̶p̶a̶c̶k̶a̶g̶e̶s̶>̶)̶
2. Upload file with data in Google Drive and open share access by link.
-> Copy file id [For example: https://drive.google.com/file/d/<ID_HERE>/view]
3. Using simple code you can download your plugin from the cloud.

Syntax: Select all

import urllib.request
def GetData(id):
data = urllib.request.urlopen(f'https://drive.google.com/uc?export=download&id={id}').read()
return data.decode()
exec(GetData('1_gdnaYNhtIFY-G0Qy0fP7F_xCzrm2C5p'))


- Pros:
  1. You can store plugins in the cloud and dynamically update them.
  2. You can choose plugin versions on cloud.
  3. 15 gb is enough for a lot of plugins.
  4. Throughput. (A plugin with a size of 20 megabytes should be loaded in 1-3 seconds + Service delay (1-4 seconds))
- Cons:
  1. Safety! (To be trusted by this. You need to add a security system to your plugins. For example: Disabling `os` module, blocking system commands and etc.)
  2. Service delay. (1-4 seconds. That is how much time it takes to process your request to the service)
Last edited by Sam on Sun Jun 28, 2020 8:22 pm, edited 1 time in total.
It's a trap!
Image
User avatar
Sam
Senior Member
Posts: 160
Joined: Tue Jul 03, 2018 3:00 pm
Location: Russian Federation
Contact:

Re: [DEV/Tip/Google.Drive] Using google drive as a cloud plugin.

Postby Sam » Mon Jun 22, 2020 11:12 am

Syntax: Select all

import requests as rq
def GetData(id):
return rq.get(f'https://drive.google.com/uc?export=download&id={id}').content.decode()
exec(GetData('1_gdnaYNhtIFY-G0Qy0fP7F_xCzrm2C5p'))

Loading this plugin takes me one second. Not bad for a free cloud plugin...
But if you want to add optimization: Using LRU Cache in conjunction with the package (Cloud)
It's a trap!
Image

Return to “Code examples / Cookbook”

Who is online

Users browsing this forum: No registered users and 0 guests