Skip to content
This repository has been archived by the owner on Nov 21, 2021. It is now read-only.

Commit

Permalink
- Added Google Login Support for Electron [Styling Necessary, Will do…
Browse files Browse the repository at this point in the history
… that tommo]

- Added Dev Enviroment to Run-Script.tsx by default so that Developer wont need to Specify [-dev] argument
- To Logout Current Google Accout for Python Scripts, Just Delete 'token.pickle' present under 'assets/installation/.usp/' directory
- To Logout Current Google Accout for Electron App, Just edit 'line no ~15' of Appsettings.json present under 'assets/installation/.usp/' to

"cloudLoginStatus": {
    "googleDrive": null
}

Eg [assets/installation/.usp/Appsettings.json] [for Logout]-

Replace -
"cloudLoginStatus": {
    "googleDrive": {
      "user": {
        "kind": "drive#user",
        "displayName": "sahil shahane",
        "me": true,
        "permissionId": "14809511190742694856",
        "emailAddress": "[email protected]"
      },
      "storageQuota": {
        "limit": "16106127360",
        "usage": "2694603157",
        "usageInDrive": "2660517007",
        "usageInDriveTrash": "236860755"
      }
    }

To -
"cloudLoginStatus": {
    "googleDrive": null
}

- Renamed 'python-scripts' folder to 'pythonScripts' which is present under 'assets' directory
- Renamed 'authenticate.py' to 'GoogleDrive.py' which is present under 'assets/pythonScripts/DrivePart' directory
- While Working in Python Scripts, Google's Service Object must be Retrived from 'getGDriveService()' function
- Fixed Width issue in FolderArea component [i guess Uttkarsh's Branch has already Fixed this issue]
- some Changes in main.dev.ts
  • Loading branch information
sahilshahane committed Dec 31, 2020
1 parent ac316fd commit 2c71fde
Show file tree
Hide file tree
Showing 43 changed files with 302 additions and 254 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ npm-debug.log.*
*.css.d.ts
*.sass.d.ts
*.scss.d.ts
token.pickle
11 changes: 11 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.8"
1 change: 1 addition & 0 deletions Testing/.usp/commit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"total": 1, "latest": {"filePath": ".usp\\data\\1609426267.json", "fileName": "1609426267.json", "commitTime": "1609426267"}}
1 change: 1 addition & 0 deletions Testing/.usp/data/1609426267.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{".\\123 - Copy (2).txt": {"fileName": "123 - Copy (2).txt", "hash": "d41d8cd98f00b204e9800998ecf8427e", "parentDir": "."},".\\123 - Copy.txt": {"fileName": "123 - Copy.txt", "hash": "d41d8cd98f00b204e9800998ecf8427e", "parentDir": "."},".\\123.txt": {"fileName": "123.txt", "hash": "d41d8cd98f00b204e9800998ecf8427e", "parentDir": "."},".\\fields.json": {"fileName": "fields.json", "hash": "d41d8cd98f00b204e9800998ecf8427e", "parentDir": "."},".\\.usp\\commit.json": {"fileName": "commit.json", "hash": "d41d8cd98f00b204e9800998ecf8427e", "parentDir": ".\\.usp"},".\\.usp\\repository.json": {"fileName": "repository.json", "hash": "d41d8cd98f00b204e9800998ecf8427e", "parentDir": ".\\.usp"},".\\.usp\\data\\1609426267.json": {"fileName": "1609426267.json", "hash": "d41d8cd98f00b204e9800998ecf8427e", "parentDir": ".\\.usp\\data"},".\\asd\\123 - Copy (2).txt": {"fileName": "123 - Copy (2).txt", "hash": "d41d8cd98f00b204e9800998ecf8427e", "parentDir": ".\\asd"},".\\asd\\123 - Copy (3).txt": {"fileName": "123 - Copy (3).txt", "hash": "d41d8cd98f00b204e9800998ecf8427e", "parentDir": ".\\asd"},".\\asd\\123 - Copy (4).txt": {"fileName": "123 - Copy (4).txt", "hash": "d41d8cd98f00b204e9800998ecf8427e", "parentDir": ".\\asd"},".\\asd\\123 - Copy.txt": {"fileName": "123 - Copy.txt", "hash": "d41d8cd98f00b204e9800998ecf8427e", "parentDir": ".\\asd"},".\\asd\\123.txt": {"fileName": "123.txt", "hash": "d41d8cd98f00b204e9800998ecf8427e", "parentDir": ".\\asd"}}
1 change: 1 addition & 0 deletions Testing/.usp/repository.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"abs_path": "D:\\Projects\\FHS\\windows\\FVS-GIT-CLONE\\Testing"}
1 change: 1 addition & 0 deletions Testing/fields.json

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions assets/entitlements.mac.plist

This file was deleted.

2 changes: 1 addition & 1 deletion assets/installation/.usp/Appsetting.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"defaultIgnores": [".usp/**"],
"profileImage_fileName": "profile.jpg",
"cloudLoginStatus": {
"googleDrive": true
"googleDrive": null
},
"theme": "dark"
}
4 changes: 3 additions & 1 deletion assets/installation/.usp/Communication_Codes.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@
"OPEN_BROWSER": 26,
"LOCAL_SERVER_STARTED": 27,
"LOCAL_SERVER_CLOSED": 28,
"PRE_INIT_REPOSITORY": 29
"PRE_INIT_REPOSITORY": 29,
"GOOGLE_USER_INFO": 30,
"GOOGLE_ID_FOUND": 31
}
Binary file modified assets/installation/.usp/token.pickle
Binary file not shown.
11 changes: 0 additions & 11 deletions assets/python-scripts/DrivePart/credentials.json

This file was deleted.

87 changes: 0 additions & 87 deletions assets/python-scripts/DrivePart/fileds.txt

This file was deleted.

30 changes: 0 additions & 30 deletions assets/python-scripts/README.md

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import json
import pickle,os,socket
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request

from log import output
import webbrowser
import wsgiref.simple_server
import wsgiref.util
Expand Down Expand Up @@ -70,18 +72,18 @@ def get_gdrive_service(CCODES):
# Save the credentials for the next run
with open(TOKEN_FILE_PATH, 'wb') as token:
pickle.dump(creds, token)

output({"code":CCODES["GOOGLE_ID_FOUND"],'msg':"Found an Google Account"})
# return Google Drive API service
service_obj = build('drive', 'v3', credentials=creds) #This the drive service object which will be used to carry out all the tasks
yield {"code":CCODES["GOOGLE_SERVICE_OBJECT"],"data": service_obj}
return build('drive', 'v3', credentials=creds) #This the drive service object which will be used to carry out all the tasks

except OSError as e:
yield {"code":CCODES["INTERNET_CONNECTION_ERROR"],"msg":str(e)}
output({"code":CCODES["INTERNET_CONNECTION_ERROR"],"msg":str(e)})
except NoGoogleIDFound as e:
yield {"code":CCODES["GOOGLE_ID_NOT_FOUND"],"msg":str(e)}

output({"code":CCODES["GOOGLE_ID_NOT_FOUND"],"msg":str(e)})

def startLogin(CCODES):
yield {"code":CCODES["GOOGLE_LOGIN_STARTED"],"msg":"Google Login Started"}
output({"code":CCODES["GOOGLE_LOGIN_STARTED"],"msg":"Google Login Started"})

try:
SCOPES = ["https://www.googleapis.com/auth/drive","https://www.googleapis.com/auth/drive.appdata"]
Expand All @@ -104,28 +106,37 @@ def startLogin(CCODES):
)

webbrowser.open(auth_url, new=1, autoraise=True)
yield {"code":CCODES["OPEN_BROWSER"],"msg":"Open your Browser, For Google Login"}
output({"code":CCODES["OPEN_BROWSER"],"msg":"Open your Browser, For Google Login"})

yield {"code":CCODES["LOCAL_SERVER_STARTED"],"msg":f"Local Server Started at http://{host}:{port}","data":{"host":host,"port":port}}
output({"code":CCODES["LOCAL_SERVER_STARTED"],"msg":f"Local Server Started at http://{host}:{port}","data":{"host":host,"port":port}})
local_server.handle_request()

yield {"code":CCODES["LOCAL_SERVER_CLOSED"],"msg":"Local Server Closed"}
output({"code":CCODES["LOCAL_SERVER_CLOSED"],"msg":"Local Server Closed"})
local_server.server_close()

# Note: using https here because oauthlib is very picky that
# OAuth 2.0 should only occur over https.
authorization_response = wsgi_app.last_request_uri.replace('http','https')
yield {"code":CCODES["GOOGLE_LOGIN_URL"],"msg":"Google Login URL","data":{"url":authorization_response}}
output({"code":CCODES["GOOGLE_LOGIN_URL"],"msg":"Google Login URL","data":{"url":authorization_response}})

flow.fetch_token(authorization_response=authorization_response)

creds = flow.credentials

output({"code":CCODES["GOOGLE_LOGIN_SUCCESS"],"msg":"Google Login Was Successfull!"})

with open(TOKEN_FILE_PATH, 'wb') as token:
pickle.dump(creds, token)
yield {"code":CCODES["GOOGLE_LOGIN_SUCCESS"],"msg":"Google Login Was Successfull!"}

return build('drive', 'v3', credentials=creds)
except OSError as e:
yield {"code":CCODES["INTERNET_CONNECTION_ERROR"],"msg":str(e)}
output({"code":CCODES["INTERNET_CONNECTION_ERROR"],"msg":str(e)})
output({"code":CCODES["GOOGLE_LOGIN_FAILED"],"msg":str(e)})
except Exception as e:
yield {"code":CCODES["GOOGLE_LOGIN_FAILED"],"msg":str(e)}
output({"code":CCODES["GOOGLE_LOGIN_FAILED"],"msg":str(e)})

def getUSERInfo(CCODES,service = None):
if(not service): service = get_gdrive_service(CCODES)
userInfo = service.about().get(fields="user,storageQuota").execute()

return userInfo
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions assets/pythonScripts/log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import json

def output(_):
print(json.dumps(_))
# pass

def output_direct(_):
print(_)
# pass
Loading

0 comments on commit 2c71fde

Please sign in to comment.