Skip to content

Commit

Permalink
bin: add the parameter disabling HTTP bootstrapping
Browse files Browse the repository at this point in the history
Particularly useful together with locally stored metadata.

I am not sure how to get rid of the need to need to provide URL
when I just want to let pyodata parse locally stored metadata.

The newly introduced option will allow me to run pyodata with
dummy URL because no request HTTP request will be send.

If you find a better User Experience, feel free to rework it.

Usage:
  pyodata DUMMY_FAKE_URL --no-session-init --metdata ./metadata.xml
  • Loading branch information
filak-sap committed Oct 24, 2019
1 parent 9fec3f2 commit 547fc1e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions bin/pyodata
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def _parse_args(argv):
parser.add_argument('--password', default=None, type=str)
parser.add_argument('--metadata', default=None, type=str,
help='Path to the XML file with service $metadata')
parser.add_argument('--no-session-init', default=False,
action='store_true', help='Skip HTTP session initialization')
parser.set_defaults(func=print_out_metadata_info)

subparsers = parser.add_subparsers()
Expand Down Expand Up @@ -97,13 +99,17 @@ def _main(argv):

session.auth = (args.user, args.password)

try:
session.head(args.SERVICE_ROOT_URL)
args.password = 'xxxxx'
except pyodata.exceptions.HttpError as err:
sys.stderr.write(str(err))
sys.stderr.write('\n')
sys.exit(1)
# Oh, I am sorry for the double negation,
# but I cannot find a better construction.
if not args.no_session_init:
print('[Initializing HTTP session ...]')
try:
session.head(args.SERVICE_ROOT_URL)
args.password = 'xxxxx'
except pyodata.exceptions.HttpError as err:
sys.stderr.write(str(err))
sys.stderr.write('\n')
sys.exit(1)

static_metadata = None
if args.metadata:
Expand Down

0 comments on commit 547fc1e

Please sign in to comment.