Browse Source

Closing #74 Bug/python3 (#87)

* remove excep handler

* update

* change print

* fix for python3

* fix for python3

* python3 changes
master
Gerry Nelson 4 years ago
committed by GitHub
parent
commit
6e77802f9e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. BIN
      __pycache__/sharedfunctions.cpython-36.pyc
  2. 19
      createbinarybackup.py
  3. 8
      deletepublishdest.py
  4. 3
      explainaccess.py
  5. 16
      getpath.py
  6. 2
      getruleid.py
  7. 21
      listallcasservercachestatus.py
  8. 4
      listcaslibs.py
  9. 8
      listcaslibsandeffectiveaccess.py
  10. 2
      listcastables.py
  11. 10
      listcastablesandeffectiveaccess.py
  12. 4
      listgroupsandmembers.py
  13. 2
      listmemberswithpath.py
  14. 2
      testfolderaccess.py

BIN
__pycache__/sharedfunctions.cpython-36.pyc

Binary file not shown.

19
createbinarybackup.py

@ -23,6 +23,14 @@
# limitations under the License. # limitations under the License.
# #
# Import Python modules
from sharedfunctions import callrestapi, getapplicationproperties
import argparse
import json
import sys
import os
# get python version # get python version
version=int(str(sys.version_info[0])) version=int(str(sys.version_info[0]))
@ -35,7 +43,6 @@ cliexe=propertylist["sascli.executable"]
clicommand=os.path.join(clidir,cliexe) clicommand=os.path.join(clidir,cliexe)
debug=False debug=False
defaultBackupScheduleName="DEFAULT_BACKUP_SCHEDULE" defaultBackupScheduleName="DEFAULT_BACKUP_SCHEDULE"
newScheduleName="BINARY_BACKUP_SCHEDULE" newScheduleName="BINARY_BACKUP_SCHEDULE"
@ -44,20 +51,12 @@ jobDefinitionURIStem="/jobDefinitions/definitions/"
newScheduleContentType="application/vnd.sas.backup.request+json" # For a single-tenant deployment newScheduleContentType="application/vnd.sas.backup.request+json" # For a single-tenant deployment
#newScheduleContentType="application/vnd.sas.backup.deployment.request+json" # For a multi-tenant deployment #newScheduleContentType="application/vnd.sas.backup.deployment.request+json" # For a multi-tenant deployment
# Import Python modules
import argparse
import json
import sys
from sharedfunctions import callrestapi
# Define exception handler so that we only output trace info from errors when in debug mode # Define exception handler so that we only output trace info from errors when in debug mode
def exception_handler(exception_type, exception, traceback, debug_hook=sys.excepthook): def exception_handler(exception_type, exception, traceback, debug_hook=sys.excepthook):
if debug: if debug:
debug_hook(exception_type, exception, traceback) debug_hook(exception_type, exception, traceback)
else: else:
print "%s: %s" % (exception_type.__name__, exception) print (exception_type.__name__, exception)
sys.excepthook = exception_handler sys.excepthook = exception_handler

8
deletepublishdest.py

@ -33,14 +33,6 @@ import argparse
import sys import sys
from sharedfunctions import callrestapi from sharedfunctions import callrestapi
# Define exception handler so that we only output trace info from errors when in debug mode
def exception_handler(exception_type, exception, traceback, debug_hook=sys.excepthook):
if debug:
debug_hook(exception_type, exception, traceback)
else:
print "%s: %s" % (exception_type.__name__, exception)
sys.excepthook = exception_handler
parser = argparse.ArgumentParser(description="Delete a publishing destination") parser = argparse.ArgumentParser(description="Delete a publishing destination")
parser.add_argument("-n","--name", help="Enter the name of the publishing destination to be deleted.",required=True) parser.add_argument("-n","--name", help="Enter the name of the publishing destination to be deleted.",required=True)

3
explainaccess.py

@ -60,6 +60,7 @@ import argparse
import subprocess import subprocess
import json import json
import sys import sys
import os
from sharedfunctions import getfolderid,callrestapi,getapplicationproperties from sharedfunctions import getfolderid,callrestapi,getapplicationproperties
# get python version # get python version
@ -86,7 +87,7 @@ def exception_handler(exception_type, exception, traceback, debug_hook=sys.excep
if debug: if debug:
debug_hook(exception_type, exception, traceback) debug_hook(exception_type, exception, traceback)
else: else:
print "%s: %s" % (exception_type.__name__, exception) print (exception_type.__name__, exception)
sys.excepthook = exception_handler sys.excepthook = exception_handler

16
getpath.py

@ -31,6 +31,12 @@
# #
# Import Python modules
import argparse
import sys
import os
from sharedfunctions import getpath, getapplicationproperties
# get python version # get python version
version=int(str(sys.version_info[0])) version=int(str(sys.version_info[0]))
@ -44,18 +50,12 @@ clicommand=os.path.join(clidir,cliexe)
debug=False debug=False
# Import Python modules
import argparse
import sys
from sharedfunctions import getpath
# Define exception handler so that we only output trace info from errors when in debug mode # Define exception handler so that we only output trace info from errors when in debug mode
def exception_handler(exception_type, exception, traceback, debug_hook=sys.excepthook): def exception_handler(exception_type, exception, traceback, debug_hook=sys.excepthook):
if debug: if debug:
debug_hook(exception_type, exception, traceback) debug_hook(exception_type, exception, traceback)
else: else:
print "%s: %s" % (exception_type.__name__, exception) print (exception_type.__name__, exception)
sys.excepthook = exception_handler sys.excepthook = exception_handler
@ -69,4 +69,4 @@ debug=args.debug
path=getpath(objecturi) path=getpath(objecturi)
if path is not None: if path is not None:
print path print (path)

2
getruleid.py

@ -44,7 +44,7 @@ def exception_handler(exception_type, exception, traceback, debug_hook=sys.excep
if debug: if debug:
debug_hook(exception_type, exception, traceback) debug_hook(exception_type, exception, traceback)
else: else:
print "%s: %s" % (exception_type.__name__, exception) print (exception_type.__name__, exception)
sys.excepthook = exception_handler sys.excepthook = exception_handler

21
listallcasservercachestatus.py

@ -36,15 +36,6 @@ import swat # pip install swat
import sys import sys
from sharedfunctions import callrestapi from sharedfunctions import callrestapi
# Define exception handler so that we only output trace info from errors when in debug mode
def exception_handler(exception_type, exception, traceback, debug_hook=sys.excepthook):
if debug:
debug_hook(exception_type, exception, traceback)
else:
print "%s: %s" % (exception_type.__name__, exception)
sys.excepthook = exception_handler
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("--noheader", action='store_true', help="Do not print the header row") parser.add_argument("--noheader", action='store_true', help="Do not print the header row")
parser.add_argument("-d","--debug", action='store_true', help="Debug") parser.add_argument("-d","--debug", action='store_true', help="Debug")
@ -55,7 +46,7 @@ debug=args.debug
# Print header row unless noheader argument was specified # Print header row unless noheader argument was specified
if not noheader: if not noheader:
print('server,host-or-ip,port,restPort, [table]') print('server,host-or-ip,port,restPort, [table]')
endpoint='/casManagement/servers' endpoint='/casManagement/servers'
method='get' method='get'
@ -77,13 +68,13 @@ for server in servers:
print(servername+','+serverhost+','+str(serverport)+','+str(serverrest)) print(servername+','+serverhost+','+str(serverport)+','+str(serverrest))
# connect to each CAS server # connect to each CAS server
s = swat.CAS(serverhost, serverport) s = swat.CAS(serverhost, serverport)
# TLS relies on env var $CAS_CLIENT_SSL_CA_LIST=/opt/sas/viya/config/etc/SASSecurityCertificateFramework/cacerts/vault-ca.crt (or local location) # TLS relies on env var $CAS_CLIENT_SSL_CA_LIST=/opt/sas/viya/config/etc/SASSecurityCertificateFramework/cacerts/vault-ca.crt (or local location)
# else "ERROR: SSL Error: Missing CA trust list" # else "ERROR: SSL Error: Missing CA trust list"
# get CAS_DISK_CACHE usage # get CAS_DISK_CACHE usage
s.accessControl.assumeRole(adminRole="superuser") # superuser role reqd s.accessControl.assumeRole(adminRole="superuser") # superuser role reqd
results = s.builtins.getCacheInfo # returns dictionary and table results = s.builtins.getCacheInfo # returns dictionary and table
# display table with CAS_DISK_CACHE usage stats # display table with CAS_DISK_CACHE usage stats
print(tabulate(results,headers='firstrow')) print(tabulate(results,headers='firstrow'))

4
listcaslibs.py

@ -39,7 +39,7 @@ def exception_handler(exception_type, exception, traceback, debug_hook=sys.excep
if debug: if debug:
debug_hook(exception_type, exception, traceback) debug_hook(exception_type, exception, traceback)
else: else:
print "%s: %s" % (exception_type.__name__, exception) print (exception_type.__name__, exception)
sys.excepthook = exception_handler sys.excepthook = exception_handler
@ -53,7 +53,7 @@ debug=args.debug
# Print header row unless noheader argument was specified # Print header row unless noheader argument was specified
if not noheader: if not noheader:
print('server,caslib') print('server,caslib')
endpoint='/casManagement/servers' endpoint='/casManagement/servers'
method='get' method='get'

8
listcaslibsandeffectiveaccess.py

@ -40,7 +40,7 @@ def exception_handler(exception_type, exception, traceback, debug_hook=sys.excep
if debug: if debug:
debug_hook(exception_type, exception, traceback) debug_hook(exception_type, exception, traceback)
else: else:
print "%s: %s" % (exception_type.__name__, exception) print (exception_type.__name__, exception)
sys.excepthook = exception_handler sys.excepthook = exception_handler
@ -85,7 +85,7 @@ for server in servers:
for caslib in caslibs: for caslib in caslibs:
caslibname=caslib['name'] caslibname=caslib['name']
#print(servername+','+caslibname) #print(servername+','+caslibname)
# Get effective Access Controls on this caslib # Get effective Access Controls on this caslib
endpoint='/casAccessManagement/servers/'+servername+'/caslibControls/'+caslibname+'?accessControlType=effective&limit=10000' endpoint='/casAccessManagement/servers/'+servername+'/caslibControls/'+caslibname+'?accessControlType=effective&limit=10000'
method='get' method='get'
@ -104,5 +104,5 @@ for server in servers:
output=output+','+ai[col] output=output+','+ai[col]
else: else:
output=output+',' output=output+','
print output print(output)

2
listcastables.py

@ -39,7 +39,7 @@ def exception_handler(exception_type, exception, traceback, debug_hook=sys.excep
if debug: if debug:
debug_hook(exception_type, exception, traceback) debug_hook(exception_type, exception, traceback)
else: else:
print "%s: %s" % (exception_type.__name__, exception) print (exception_type.__name__, exception)
sys.excepthook = exception_handler sys.excepthook = exception_handler

10
listcastablesandeffectiveaccess.py

@ -40,7 +40,7 @@ def exception_handler(exception_type, exception, traceback, debug_hook=sys.excep
if debug: if debug:
debug_hook(exception_type, exception, traceback) debug_hook(exception_type, exception, traceback)
else: else:
print "%s: %s" % (exception_type.__name__, exception) print (exception_type.__name__, exception)
sys.excepthook = exception_handler sys.excepthook = exception_handler
@ -60,7 +60,7 @@ debug=args.debug
if rowlevelsecurity: if rowlevelsecurity:
permissions.append("tableFilter") permissions.append("tableFilter")
# Print header row unless noheader argument was specified # Print header row unless noheader argument was specified
if not noheader: if not noheader:
print('server,caslib,table,'+','.join(map(str, identity_cols))+','+','.join(map(str, permissions))) print('server,caslib,table,'+','.join(map(str, identity_cols))+','+','.join(map(str, permissions)))
@ -93,7 +93,7 @@ for server in servers:
for caslib in caslibs: for caslib in caslibs:
caslibname=caslib['name'] caslibname=caslib['name']
#print(servername+','+caslibname) #print(servername+','+caslibname)
# Get the tables in the caslib # Get the tables in the caslib
endpoint='/casManagement/servers/'+servername+'/caslibs/'+caslibname+'/tables?excludeItemLinks=true&limit=10000' endpoint='/casManagement/servers/'+servername+'/caslibs/'+caslibname+'/tables?excludeItemLinks=true&limit=10000'
method='get' method='get'
@ -116,8 +116,8 @@ for server in servers:
# We have the in-memory table name, but if the user requested it, try to use the source table name instead # We have the in-memory table name, but if the user requested it, try to use the source table name instead
if sourcetables and 'tableReference' in table: if sourcetables and 'tableReference' in table:
if 'sourceTableName' in table['tableReference']: if 'sourceTableName' in table['tableReference']:
tablename=table['tableReference']['sourceTableName'] tablename=table['tableReference']['sourceTableName']
# Get effective Access Controls on this table # Get effective Access Controls on this table
endpoint='/casAccessManagement/servers/'+servername+'/caslibs/'+caslibname+'/tableControls/'+tablename+'?accessControlType=effective' endpoint='/casAccessManagement/servers/'+servername+'/caslibs/'+caslibname+'/tableControls/'+tablename+'?accessControlType=effective'
method='get' method='get'

4
listgroupsandmembers.py

@ -43,7 +43,7 @@ def exception_handler(exception_type, exception, traceback, debug_hook=sys.excep
if debug: if debug:
debug_hook(exception_type, exception, traceback) debug_hook(exception_type, exception, traceback)
else: else:
print "%s: %s" % (exception_type.__name__, exception) print (exception_type.__name__, exception)
sys.excepthook = exception_handler sys.excepthook = exception_handler
@ -82,7 +82,7 @@ for group in groups:
groupproviderid=group['providerId'] groupproviderid=group['providerId']
if groupid!="": # Skip groups with empty id (this has been seen at least once at a customer site), because we cannot fetch their members. if groupid!="": # Skip groups with empty id (this has been seen at least once at a customer site), because we cannot fetch their members.
# List the members of this group # List the members of this group
endpoint='/identities/groups/'+groupid+'/members?limit=10000' endpoint='/identities/groups/'+groupid+'/members?limit=10000'
method='get' method='get'

2
listmemberswithpath.py

@ -42,7 +42,7 @@ def exception_handler(exception_type, exception, traceback, debug_hook=sys.excep
if debug: if debug:
debug_hook(exception_type, exception, traceback) debug_hook(exception_type, exception, traceback)
else: else:
print "%s: %s" % (exception_type.__name__, exception) print (exception_type.__name__, exception)
sys.excepthook = exception_handler sys.excepthook = exception_handler

2
testfolderaccess.py

@ -54,7 +54,7 @@ def exception_handler(exception_type, exception, traceback, debug_hook=sys.excep
if debug: if debug:
debug_hook(exception_type, exception, traceback) debug_hook(exception_type, exception, traceback)
else: else:
print "%s: %s" % (exception_type.__name__, exception) print (exception_type.__name__, exception)
sys.excepthook = exception_handler sys.excepthook = exception_handler

Loading…
Cancel
Save