|
8 | 8 | import urllib3
|
9 | 9 | import urllib
|
10 | 10 | import json
|
11 |
| -# import webbrowser |
| 11 | +import webbrowser |
12 | 12 | import Server
|
13 | 13 |
|
14 | 14 | import nut
|
|
28 | 28 | import socket
|
29 | 29 |
|
30 | 30 | import sys
|
31 |
| -from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QAction, QTableWidget,QTableWidgetItem,QVBoxLayout,QDesktopWidget, QTabWidget, QProgressBar, QLabel,QHBoxLayout, QLineEdit, QPushButton, QCheckBox |
| 31 | +from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QAction, QTableWidget,QTableWidgetItem,QVBoxLayout,QDesktopWidget, QTabWidget, QProgressBar, QLabel,QHBoxLayout, QLineEdit, QPushButton, QCheckBox, QMessageBox |
32 | 32 | from PyQt5.QtGui import QIcon
|
33 | 33 | from PyQt5.QtCore import pyqtSlot,Qt,QTimer
|
34 | 34 | from PyQt5 import QtWidgets
|
@@ -58,6 +58,10 @@ def __init__(self, app):
|
58 | 58 | self.scan = QPushButton('Scan', app)
|
59 | 59 | self.scan.clicked.connect(app.on_scan)
|
60 | 60 | self.layout.addWidget(self.scan)
|
| 61 | + |
| 62 | + self.gdrive = QPushButton('Setup GDrive OAuth', app) |
| 63 | + self.gdrive.clicked.connect(app.on_gdrive) |
| 64 | + self.layout.addWidget(self.gdrive) |
61 | 65 |
|
62 | 66 | # self.autolaunchBrowser = QCheckBox("Launch Web Browser?", app)
|
63 | 67 | # self.autolaunchBrowser.setChecked(Config.autolaunchBrowser)
|
@@ -144,7 +148,7 @@ def __init__(self):
|
144 | 148 | super().__init__()
|
145 | 149 | self.setWindowIcon(QIcon('public_html/images/logo.jpg'))
|
146 | 150 | screen = QDesktopWidget().screenGeometry()
|
147 |
| - self.title = 'NUT USB / Web Server v2.6' |
| 151 | + self.title = 'NUT USB / Web Server v2.7' |
148 | 152 | self.left = screen.width() / 4
|
149 | 153 | self.top = screen.height() / 4
|
150 | 154 | self.width = screen.width() / 2
|
@@ -202,6 +206,28 @@ def on_scan(self):
|
202 | 206 | self.tableWidget.setRowCount(0)
|
203 | 207 | nut.scan()
|
204 | 208 | self.refreshTable()
|
| 209 | + |
| 210 | + @pyqtSlot() |
| 211 | + def on_gdrive(self): |
| 212 | + if Config.getGdriveCredentialsFile() is None: |
| 213 | + webbrowser.open_new_tab('https://developers.google.com/drive/api/v3/quickstart/go') |
| 214 | + QMessageBox.information(self, 'Google Drive OAuth Setup', "You require a credentials.json file to set up Google Drive OAuth. This file can be obtained from https://developers.google.com/drive/api/v3/quickstart/go , click on the blue button that says 'Enable the Drive API' and save the credentials.json to t his application's directory.") |
| 215 | + else: |
| 216 | + buttonReply = QMessageBox.question(self, 'Google Drive OAuth Setup', "Do you you want to setup GDrive OAuth?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No) |
| 217 | + |
| 218 | + if buttonReply == QMessageBox.Yes: |
| 219 | + try: |
| 220 | + os.unlink('gdrive.token') |
| 221 | + except: |
| 222 | + pass |
| 223 | + |
| 224 | + try: |
| 225 | + os.unlink('token.pickle') |
| 226 | + except: |
| 227 | + pass |
| 228 | + |
| 229 | + Server.Controller.Api.getGdriveToken(None, None) |
| 230 | + QMessageBox.information(self, 'Google Drive OAuth Setup', "OAuth has completed. Please copy gdrive.token and credentials.json to your Nintendo Switch's sdmc:/switch/tinfoil/ and/or sdmc:/switch/sx/ directories.") |
205 | 231 |
|
206 | 232 | @pyqtSlot()
|
207 | 233 | def refreshTable(self):
|
|
0 commit comments