Skip to content

Commit 73f09ba

Browse files
cmickeybprakashngit
authored andcommitted
drop the quiet option from the pdo-shell commands
the quiet option was realistically required for every pdo-shell commands, but was never actually being used. this removes it from the stock pdo-shell commands. you can still get results by requesting the results in a symbol and then echoing the symbol value. Signed-off-by: Mic Bowman <[email protected]>
1 parent 75f224c commit 73f09ba

File tree

33 files changed

+198
-239
lines changed

33 files changed

+198
-239
lines changed

build/opt/pdo/etc/template/site.psh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if --null "${data}"
2020
fi
2121

2222
## load the local database if it exists
23-
set -q --conditional -s dbfile --state Service EnclaveServiceDatabaseFile
23+
set --conditional -s dbfile --state Service EnclaveServiceDatabaseFile
2424

2525
## this returns false of the database file does not exist
2626
## we can use this later to save the updates

build/tests/shell-test.psh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
## See the License for the specific language governing permissions and
1515
## limitations under the License.
1616

17-
set -q --conditional -s data -v .
18-
set -q --conditional -s save -v .
17+
st --conditional -s data -v .
18+
st --conditional -s save -v .
1919

2020
## create an eservice db with the known enclave services
2121
eservice_db clear
@@ -61,15 +61,15 @@ eservice --group all add --url http://localhost:7102 http://localhost:7103 --nam
6161
eservice --group all use --name es7104
6262

6363
## create some contracts
64-
set -q -s contract1 -r 32
65-
set -q -s contract2 -r 32
66-
set -q -s contract3 -r 32
64+
set -s contract1 -r 32
65+
set -s contract2 -r 32
66+
set -s contract3 -r 32
6767

6868
identity -n user1
6969
create -c mock-contract -s _mock-contract -f ${save}/${contract1}.pdo
70-
send -q -f ${save}/${contract1}.pdo inc_value
71-
send -q -f ${save}/${contract1}.pdo inc_value
72-
send -q -f ${save}/${contract1}.pdo -s value inc_value
70+
send -f ${save}/${contract1}.pdo inc_value
71+
send -f ${save}/${contract1}.pdo inc_value
72+
send -f ${save}/${contract1}.pdo -s value inc_value
7373
if -e ${value} 3
7474
echo shell test 1 succeeded
7575
else
@@ -79,11 +79,11 @@ fi
7979

8080
identity -n user2
8181
create -c mock-contract -s _mock-contract -p all -e all -f ${save}/${contract2}.pdo
82-
send -q -f ${save}/${contract2}.pdo --wait inc_value -e http://localhost:7101
83-
send -q -f ${save}/${contract2}.pdo --wait inc_value -e http://localhost:7102
84-
send -q -f ${save}/${contract2}.pdo --wait inc_value -e random
85-
send -q -f ${save}/${contract2}.pdo --wait inc_value -e random
86-
send -q -f ${save}/${contract2}.pdo get_value -s value
82+
send -f ${save}/${contract2}.pdo --wait inc_value -e http://localhost:7101
83+
send -f ${save}/${contract2}.pdo --wait inc_value -e http://localhost:7102
84+
send -f ${save}/${contract2}.pdo --wait inc_value -e random
85+
send -f ${save}/${contract2}.pdo --wait inc_value -e random
86+
send -f ${save}/${contract2}.pdo get_value -s value
8787
if -e ${value} 4
8888
echo shell test 2 succeeded
8989
else
@@ -93,10 +93,10 @@ fi
9393

9494
identity -n user3
9595
create -c mock-contract -s _mock-contract -p p1 -e e1 -f ${save}/${contract3}.pdo
96-
send -q -f ${save}/${contract3}.pdo inc_value -s r8 -e preferred
97-
send -q -f ${save}/${contract3}.pdo inc_value -s r9 -e random
98-
send -q -f ${save}/${contract3}.pdo inc_value -s r10 -e random
99-
send -q -f ${save}/${contract3}.pdo get_value -s value
96+
send -f ${save}/${contract3}.pdo inc_value -s r8 -e preferred
97+
send -f ${save}/${contract3}.pdo inc_value -s r9 -e random
98+
send -f ${save}/${contract3}.pdo inc_value -s r10 -e random
99+
send -f ${save}/${contract3}.pdo get_value -s value
100100
if -e ${value} 3
101101
echo shell test 3 succeeded
102102
else

client/bin/pdo-create.psh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@
2929
##
3030
## $ ./pdo-create.psh -m class <class> -m source <source> -m identity <identity>
3131

32-
set -q --conditional -s data -v .
33-
set -q --conditional -s save -v .
32+
set --conditional -s data -v .
33+
set --conditional -s save -v .
3434
script -f ${home}/etc/site.psh
3535

3636
## create a random string that uniquely identifies the contract
3737
## that we are going to create
38-
set -q -s random_id -r 32
38+
set -s random_id -r 32
3939

40-
set -q --conditional -s psgroup -v default
41-
set -q --conditional -s esgroup -v default
42-
set -q --conditional -s pdo_file -v ${save}/${random_id}.pdo
40+
set --conditional -s psgroup -v default
41+
set --conditional -s esgroup -v default
42+
set --conditional -s pdo_file -v ${save}/${random_id}.pdo
4343

4444
## class
4545
## source

client/bin/pdo-invoke.psh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
## identity -- the identity of the contract creator
2828
## $ ./pdo-invoke.psh -m contract <contract> -expr <expression> -m identity <identity>
2929

30-
set -q --conditional -s data -v .
31-
set -q --conditional -s params -v ""
32-
set -q --conditional -s method -v ""
30+
set --conditional -s data -v .
31+
set --conditional -s params -v ""
32+
set --conditional -s method -v ""
3333

3434
script -f ${home}/etc/site.psh
3535

@@ -53,14 +53,15 @@ fi
5353
trap_error
5454

5555
if -n ${params}
56-
send -f ${pdo_file} ${method}
56+
send -s _result_ -f ${pdo_file} ${method}
5757
else
58-
send -f ${pdo_file} -p ${params} ${method}
58+
send -s _result_ -f ${pdo_file} -p ${params} ${method}
5959
fi
6060

6161
if -o ${_error_code_} 0
6262
echo ERROR: ${_error_message_}
6363
exit -v ${_error_code_}
6464
fi
6565

66+
echo ${_result_}
6667
exit

client/pdo/client/controller/commands/contract.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def command_contract(state, bindings, pargs) :
3232
"""
3333

3434
parser = argparse.ArgumentParser(prog='contract')
35-
parser.add_argument('-q', '--quiet', help='Do not print the result', action='store_true')
3635
parser.add_argument('-s', '--symbol', help='binding symbol for result', type=str)
3736
parser.add_argument('-f', '--save-file', help='File where contract data is stored', type=str, required=True)
3837

@@ -62,8 +61,6 @@ def command_contract(state, bindings, pargs) :
6261
if options.command == 'code-nonce' :
6362
result = contract.contract_code.nonce
6463

65-
if result and not options.quiet :
66-
print(result)
6764
if result and options.symbol :
6865
bindings.bind(options.symbol, result)
6966

client/pdo/client/controller/commands/eservice_db.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ def command_eservice_db(state, bindings, pargs) :
3535
"""
3636

3737
parser = argparse.ArgumentParser(prog='eservice_db')
38-
parser.add_argument('-q', '--quiet', help='Do not print the result', action='store_true')
39-
4038
subparsers = parser.add_subparsers(dest='command')
4139

4240
add_parser = subparsers.add_parser('add', description='add an eservice to the database')
@@ -111,9 +109,6 @@ def command_eservice_db(state, bindings, pargs) :
111109
if options.field :
112110
result = enclave[options.field]
113111

114-
if not options.quiet :
115-
print(json.dumps(result, indent=4, sort_keys=True))
116-
117112
if options.symbol :
118113
bindings.bind(options.symbol, result)
119114

client/pdo/client/controller/commands/ledger.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def command_ledger(state, bindings, pargs) :
3232

3333
parser = argparse.ArgumentParser(prog='ledger')
3434
parser.add_argument('--url', help='URL for the ledger', default=default_ledger_url)
35-
parser.add_argument('-q', '--quiet', help='Do not print the result', action='store_true')
3635
parser.add_argument('-s', '--symbol', help='binding symbol for result', type=str)
3736

3837
subparsers = parser.add_subparsers(dest='command')
@@ -63,9 +62,7 @@ def command_ledger(state, bindings, pargs) :
6362

6463
if options.command == 'ledger-key' :
6564
result = submitter.get_ledger_info()
66-
if result and not options.quiet :
67-
print(result)
68-
if result and options.symbol :
65+
if options.symbol :
6966
bindings.bind(options.symbol, result)
7067
return
7168

@@ -74,38 +71,30 @@ def command_ledger(state, bindings, pargs) :
7471
result = submitter.get_enclave_info(options.enclave_id)
7572
if options.path :
7673
result = eval(options.path, None, result)
77-
if result and not options.quiet :
78-
print(result)
79-
if result and options.symbol :
74+
if options.symbol :
8075
bindings.bind(options.symbol, json.dumps(result))
8176
return
8277

8378
if options.command == 'contract-info' :
8479
result = submitter.get_contract_info(options.contract_id)
8580
if options.path :
8681
result = eval(options.path, None, result)
87-
if result and not options.quiet :
88-
print(result)
89-
if result and options.symbol :
82+
if options.symbol :
9083
bindings.bind(options.symbol, json.dumps(result))
9184
return
9285

9386
if options.command == 'current-state' :
9487
result = submitter.get_current_state_hash(options.contract_id)
9588
if options.path :
9689
result = eval(options.path, None, result)
97-
if result and not options.quiet :
98-
print(result)
99-
if result and options.symbol :
90+
if options.symbol :
10091
bindings.bind(options.symbol, json.dumps(result))
10192
return
10293

10394
if options.command == 'state-info' :
10495
result = submitter.get_state_details(options.contract_id, options.state_hash)
10596
if options.path :
10697
result = eval(options.path, None, result)
107-
if result and not options.quiet :
108-
print(result)
109-
if result and options.symbol :
98+
if options.symbol :
11099
bindings.bind(options.symbol, json.dumps(result))
111100
return

client/pdo/client/controller/commands/send.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
## -----------------------------------------------------------------
3535
## -----------------------------------------------------------------
36-
def send_to_contract(state, save_file, message, eservice_url=None, quiet=False, wait=False, commit=True) :
36+
def send_to_contract(state, message, save_file, eservice_url=None, wait=False, commit=True) :
3737

3838
# ---------- load the invoker's keys ----------
3939
try :
@@ -84,17 +84,8 @@ def send_to_contract(state, save_file, message, eservice_url=None, quiet=False,
8484
raise Exception('enclave failed to evaluate expression; {0}'.format(str(e)))
8585

8686
if not update_response.status :
87-
# not sure if this should throw an exception which would
88-
# terminate the script or if it should just return an
89-
# empty string that can be tested for later
90-
# if not quiet :
91-
# print("FAILED: {0}".format(update_response.invocation_response))
92-
# return ''
9387
raise ValueError(update_response.invocation_response)
9488

95-
if not quiet :
96-
print(update_response.invocation_response)
97-
9889
data_directory = state.get(['Contract', 'DataDirectory'])
9990
ledger_config = state.get(['Ledger'])
10091

@@ -135,7 +126,6 @@ def command_send(state, bindings, pargs) :
135126
parser.add_argument('-f', '--save-file', help='File where contract data is stored', type=str)
136127
parser.add_argument('-p', '--positional', help='JSON encoded list of positional parameters', type=invocation_parameter)
137128
parser.add_argument('-s', '--symbol', help='Save the result in a symbol for later use', type=str)
138-
parser.add_argument('-q', '--quiet', help='Do not print the result', action='store_true')
139129
parser.add_argument('--wait', help='Wait for the transaction to commit', action = 'store_true')
140130

141131
parser.add_argument('-k', '--kwarg',
@@ -174,10 +164,9 @@ def command_send(state, bindings, pargs) :
174164

175165
result = send_to_contract(
176166
state,
177-
options.save_file,
178167
message,
168+
options.save_file,
179169
eservice_url=options.enclave,
180-
quiet=options.quiet,
181170
wait=options.wait)
182171
if options.symbol :
183172
bindings.bind(options.symbol, result)

client/pdo/client/controller/contract_controller.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,10 @@ def do_sleep(self, args) :
372372
pargs = self.__arg_parse__(args)
373373

374374
parser = argparse.ArgumentParser(prog='sleep')
375-
parser.add_argument('-q', '--quiet', help='suppress printing the result', action='store_true')
376375
parser.add_argument('-t', '--time', help='time to sleep', type=int, required=True)
377376

378377
options = parser.parse_args(pargs)
379378

380-
if not options.quiet :
381-
print("Sleeping for {} seconds".format(options.time))
382379
time.sleep(options.time)
383380

384381
except SystemExit as se :
@@ -398,7 +395,6 @@ def do_parse(self, args) :
398395
pargs = self.__arg_parse__(args)
399396

400397
parser = argparse.ArgumentParser(prog='parse')
401-
parser.add_argument('-q', '--quiet', help='suppress printing the result', action='store_true')
402398
parser.add_argument('-e', '--expression', help='json expression to parse', type=str, required=True)
403399
parser.add_argument('-p', '--path', help='path to retrieve within the expression', type=str, required=True)
404400
parser.add_argument('-s', '--symbol', help='symbol in which to store the result', required=True)
@@ -418,8 +414,6 @@ def do_parse(self, args) :
418414
value = json.dumps(python_value)
419415

420416
self.bindings.bind(options.symbol,value)
421-
if not options.quiet :
422-
print("${} = {}".format(options.symbol, value))
423417

424418
except SystemExit as se :
425419
return self.__arg_error__('parse', args, se.code)
@@ -438,7 +432,6 @@ def do_set(self, args) :
438432
pargs = self.__arg_parse__(args)
439433

440434
parser = argparse.ArgumentParser(prog='set')
441-
parser.add_argument('-q', '--quiet', help='suppress printing the result', action='store_true')
442435
parser.add_argument('-s', '--symbol', help='symbol in which to store the identifier', required=True)
443436
parser.add_argument('-c', '--conditional', help='set the value only if it is undefined', action='store_true')
444437

@@ -473,8 +466,6 @@ def do_set(self, args) :
473466
value = self.state.get(options.state)
474467

475468
self.bindings.bind(options.symbol,value)
476-
if not options.quiet :
477-
print("${} = {}".format(options.symbol, value))
478469

479470
except SystemExit as se :
480471
return self.__arg_error__('set', args, se.code)

contracts/auction/scripts/bid.psh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
## The maps for "bidkey" and "bidval" must be specified to run this
2323
## script.
2424

25-
set -q --conditional -s data -v .
26-
set -q --conditional -s save -v .
25+
set --conditional -s data -v .
26+
set --conditional -s save -v .
2727
script -f ${path}/init.psh
2828

2929
if --null ${key}

0 commit comments

Comments
 (0)