Skip to content

Commit 0514b40

Browse files
authored
Merge pull request #49 from equinor/119166
Added console script
2 parents 90fc2f1 + 7ede804 commit 0514b40

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'Programming Language :: Python :: 3.8'
1616
],
1717
version='0.1.1',
18-
author='Lindvar Lagran',
18+
author='Equinor ASA',
1919
author_email='llag@equinor.com',
2020
install_requires=[
2121
'requests',
@@ -28,4 +28,7 @@
2828
package_dir={"": "src"},
2929
include_package_data=True,
3030
zip_safe=False,
31+
entry_points={
32+
"console_scripts": ["sumologin = sumo.wrapper.login:main"]
33+
}
3134
)

src/sumo/wrapper/_auth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def __init__(self, client_id, resource_id, authority=AUTHORITY_URI, client_crede
2929
if self._cache_available():
3030
if not self.accounts:
3131
print("Token cache found but have no accounts")
32+
self._oauth_device_code()
3233
else:
3334
print("Get token and maybe refresh")
3435
self._oauth_get_token_silent()

src/sumo/wrapper/login.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
import sys
3+
from argparse import ArgumentParser
4+
from sumo.wrapper import CallSumoApi
5+
6+
7+
def get_parser() -> ArgumentParser:
8+
parser = ArgumentParser(
9+
description="Login to Sumo on azure"
10+
)
11+
parser.add_argument(
12+
"--env", dest="env", action='store', default="prod", help="Environment to log into"
13+
)
14+
return parser
15+
16+
17+
def main():
18+
args = get_parser().parse_args()
19+
20+
env = args.env
21+
22+
print("Login to Sumo environment: " + env)
23+
24+
id = CallSumoApi(env=env)
25+
26+
if __name__ == '__main__':
27+
main()

0 commit comments

Comments
 (0)