mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-08 21:53:36 +00:00
Merge branch 'master' of https://github.com/jay0lee/GAM
This commit is contained in:
72
src/gam-setup.bat
Normal file
72
src/gam-setup.bat
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
@echo(
|
||||||
|
@set /p adminemail= "Please enter your G Suite admin email address: "
|
||||||
|
|
||||||
|
:createproject
|
||||||
|
@echo(
|
||||||
|
@set /p yn= "Are you ready to set up a Google API project for GAM? [y or n] "
|
||||||
|
@if /I "%yn%"=="n" (
|
||||||
|
@ echo(
|
||||||
|
@ echo You can create an API project later by running:
|
||||||
|
@ echo(
|
||||||
|
@ echo gam create project
|
||||||
|
@ goto alldone
|
||||||
|
)
|
||||||
|
@if /I not "%yn%"=="y" (
|
||||||
|
@ echo(
|
||||||
|
@ echo Please answer y or n.
|
||||||
|
@ goto createproject
|
||||||
|
)
|
||||||
|
@gam create project %adminemail%
|
||||||
|
@if not ERRORLEVEL 1 goto projectdone
|
||||||
|
@echo(
|
||||||
|
@echo Projection creation failed. Trying again. Say n to skip projection creation.
|
||||||
|
@goto createproject
|
||||||
|
:projectdone
|
||||||
|
|
||||||
|
:adminauth
|
||||||
|
@echo(
|
||||||
|
@set /p yn= "Are you ready to authorize GAM to perform G Suite management operations as your admin account? [y or n] "
|
||||||
|
@if /I "%yn%"=="n" (
|
||||||
|
@ echo(
|
||||||
|
@ echo You can authorize an admin later by running:
|
||||||
|
@ echo(
|
||||||
|
@ echo gam oauth create %adminemail%
|
||||||
|
@ goto admindone
|
||||||
|
)
|
||||||
|
@if /I not "%yn%"=="y" (
|
||||||
|
@ echo(
|
||||||
|
@ echo Please answer y or n.
|
||||||
|
@ goto adminauth
|
||||||
|
)
|
||||||
|
@gam oauth create %adminemail%
|
||||||
|
@if not ERRORLEVEL 1 goto admindone
|
||||||
|
@echo(
|
||||||
|
@echo Admin authorization failed. Trying again. Say n to skip admin authorization.
|
||||||
|
@goto adminauth
|
||||||
|
:admindone
|
||||||
|
|
||||||
|
:saauth
|
||||||
|
@echo(
|
||||||
|
@set /p yn= "Are you ready to authorize GAM to manage G Suite user data and settings? [y or n] "
|
||||||
|
@if /I "%yn%"=="n" (
|
||||||
|
@ echo(
|
||||||
|
@ echo You can authorize a service account later by running:
|
||||||
|
@ echo(
|
||||||
|
@ echo gam user %adminemail% check serviceaccount
|
||||||
|
@ goto sadone
|
||||||
|
)
|
||||||
|
@if /I not "%yn%"=="y" (
|
||||||
|
@ echo(
|
||||||
|
@ echo Please answer y or n.
|
||||||
|
@ goto saauth
|
||||||
|
)
|
||||||
|
@echo Great! Checking service account scopes. This will fail the first time. Follow the steps to authorize and retry. It can take a few minutes for scopes to PASS after they've been authorized in the admin console.
|
||||||
|
@gam user %adminemail% check serviceaccount
|
||||||
|
@if not ERRORLEVEL 1 goto sadone
|
||||||
|
@echo(
|
||||||
|
@echo Service account authorization failed. Confirm you entered the scopes correctly in the admin console. It can take a few minutes for scopes to PASS after they are entered in the admin console so if you're sure you entered them correctly, go grab a coffee and then hit Y to try again. Say N to skip admin authorization.
|
||||||
|
@goto saauth
|
||||||
|
:sadone
|
||||||
|
|
||||||
|
echo GAM installation and setup complete!
|
||||||
|
:alldone
|
10
src/gam.py
10
src/gam.py
@ -428,7 +428,7 @@ def indentMultiLineText(message, n=0):
|
|||||||
return message.replace(u'\n', u'\n{0}'.format(u' '*n)).rstrip()
|
return message.replace(u'\n', u'\n{0}'.format(u' '*n)).rstrip()
|
||||||
|
|
||||||
def showUsage():
|
def showUsage():
|
||||||
doGAMVersion(checkForCheck=False)
|
doGAMVersion(checkForArgs=False)
|
||||||
print u'''
|
print u'''
|
||||||
Usage: gam [OPTIONS]...
|
Usage: gam [OPTIONS]...
|
||||||
|
|
||||||
@ -818,13 +818,13 @@ def doGAMCheckForUpdates(forceCheck=False):
|
|||||||
except (urllib2.HTTPError, urllib2.URLError):
|
except (urllib2.HTTPError, urllib2.URLError):
|
||||||
return
|
return
|
||||||
|
|
||||||
def doGAMVersion(checkForCheck=True):
|
def doGAMVersion(checkForArgs=True):
|
||||||
force_check = False
|
force_check = False
|
||||||
simple = False
|
simple = False
|
||||||
|
if checkForArgs:
|
||||||
i = 2
|
i = 2
|
||||||
while i < len(sys.argv):
|
while i < len(sys.argv):
|
||||||
myarg = sys.argv[i].lower().replace(u'_', u'')
|
myarg = sys.argv[i].lower().replace(u'_', u'')
|
||||||
force_check = True
|
|
||||||
if myarg == u'check':
|
if myarg == u'check':
|
||||||
force_check = True
|
force_check = True
|
||||||
i += 1
|
i += 1
|
||||||
@ -836,14 +836,14 @@ def doGAMVersion(checkForCheck=True):
|
|||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
if simple:
|
if simple:
|
||||||
sys.stdout.write(__version__)
|
sys.stdout.write(__version__)
|
||||||
sys.exit(0)
|
return
|
||||||
import struct
|
import struct
|
||||||
version_data = u'GAM {0} - {1}\n{2}\nPython {3}.{4}.{5} {6}-bit {7}\ngoogle-api-python-client {8}\n{9} {10}\nPath: {11}'
|
version_data = u'GAM {0} - {1}\n{2}\nPython {3}.{4}.{5} {6}-bit {7}\ngoogle-api-python-client {8}\n{9} {10}\nPath: {11}'
|
||||||
print version_data.format(__version__, GAM_URL, __author__, sys.version_info[0],
|
print version_data.format(__version__, GAM_URL, __author__, sys.version_info[0],
|
||||||
sys.version_info[1], sys.version_info[2], struct.calcsize(u'P')*8,
|
sys.version_info[1], sys.version_info[2], struct.calcsize(u'P')*8,
|
||||||
sys.version_info[3], googleapiclient.__version__, platform.platform(),
|
sys.version_info[3], googleapiclient.__version__, platform.platform(),
|
||||||
platform.machine(), GM_Globals[GM_GAM_PATH])
|
platform.machine(), GM_Globals[GM_GAM_PATH])
|
||||||
if checkForCheck or force_check:
|
if force_check:
|
||||||
doGAMCheckForUpdates(forceCheck=True)
|
doGAMCheckForUpdates(forceCheck=True)
|
||||||
|
|
||||||
def handleOAuthTokenError(e, soft_errors):
|
def handleOAuthTokenError(e, soft_errors):
|
||||||
|
Reference in New Issue
Block a user