-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathAccessControl.py
executable file
·49 lines (37 loc) · 1.53 KB
/
AccessControl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
#
# Licensed under the Universal Permissive License v 1.0 as shown
# at http://oss.oracle.com/licenses/upl
#
# DESCRIPTION
# Provides functions to get the usernames and passwords
# for the samples.
#
def parseArgs():
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-u", "--user", dest="user", help="username for login")
parser.add_option("-p", "--password", dest="password", help="password for login")
parser.add_option("-c", "--connstr", dest="connstr", help="connection string",
default="localhost/sampledb:timesten_direct")
options, args = parser.parse_args()
return options;
def usage(scriptName):
return """
Usage: python {script} -u <userName> -p <password> [-c <connectionString>]
To run the sample, pass the following parameters to the sample program:
Required:
-u <username>: database user name
-p <password>: database password for the user
Optional:
-c <connectionString>: Use the specified connection string (Default: "localhost/sampledb:timesten_direct")
<connectionString> should be in Easy-Connect format:
{{<net_service_name> | <host>/<host_service_name>:{{ timesten_direct | timesten_client }}}}
""".format(script = scriptName)
def getCredentials(scriptName):
args = parseArgs()
if args.user == None or args.password == None:
print(usage(scriptName))
raise Exception("Error: Bad options format")
return args