Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

align headers, clean up imports & fix typo #17

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/module_utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
URL_SERVICE_INCIDENT = 'https://launchpad.support.sap.com/services/odata/incidentws'
URL_SERVICE_USER_ADMIN = 'https://launchpad.support.sap.com/services/odata/useradminsrv'
URL_SOFTWARE_DOWNLOAD = 'https://softwaredownloads.sap.com'
# Maintainance Planner
URL_MAINTAINANCE_PLANNER = 'https://maintenanceplanner.cfapps.eu10.hana.ondemand.com'
# Maintenance Planner
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed typo

URL_MAINTENANCE_PLANNER = 'https://maintenanceplanner.cfapps.eu10.hana.ondemand.com'
URL_USERAPPS = 'https://userapps.support.sap.com/sap/support/mp/index.html'
URL_USERAPP_MP_SERVICE = 'https://userapps.support.sap.com/sap/support/mnp/services'
URL_LEGACY_MP_API = 'https://tech.support.sap.com/sap/support/mnp/services'
Expand Down
3 changes: 0 additions & 3 deletions plugins/module_utils/sap_api_common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import logging
import re
from urllib.parse import urlparse
Expand Down
3 changes: 0 additions & 3 deletions plugins/module_utils/sap_id_sso.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import json
import logging
import re
Expand Down
13 changes: 4 additions & 9 deletions plugins/module_utils/sap_launchpad_maintenance_planner_runner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#!/user/bin/env python3
# coding: utf-8

import os
import pathlib
import re
import time
Expand All @@ -11,11 +7,10 @@
from bs4 import BeautifulSoup
from lxml import etree
from requests.auth import HTTPBasicAuth
from requests.sessions import session

from . import constants as C
from .sap_api_common import _request, https_session
from .sap_id_sso import _get_sso_endpoint_meta, sap_sso_login
from .sap_id_sso import _get_sso_endpoint_meta
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was no reference to sap_sso_login in this file, causing linters to complain - so I moved the imports into the files that actually reference the sap_sso_login function.


_MP_XSRF_TOKEN = None
_MP_TRANSACTIONS = None
Expand All @@ -24,7 +19,7 @@
def auth_maintenance_planner():
# Clear mp relevant cookies for avoiding unexpected responses.
_clear_mp_cookies('maintenanceplanner')
res = _request(C.URL_MAINTAINANCE_PLANNER)
res = _request(C.URL_MAINTENANCE_PLANNER)
sig_re = re.compile('signature=(.*?);path=\/";location="(.*)"')
signature, redirect = re.search(sig_re, res.text).groups()

Expand All @@ -35,7 +30,7 @@ def auth_maintenance_planner():
'locationAfterLogin': '%2F'
}

MP_DOMAIN = C.URL_MAINTAINANCE_PLANNER.replace('https://', '')
MP_DOMAIN = C.URL_MAINTENANCE_PLANNER.replace('https://', '')
for k, v in mp_cookies.items():
https_session.cookies.set(k, v, domain=MP_DOMAIN, path='/')

Expand Down Expand Up @@ -68,7 +63,7 @@ def auth_userapps():


def get_mp_user_details():
url = urljoin(C.URL_MAINTAINANCE_PLANNER,
url = urljoin(C.URL_MAINTENANCE_PLANNER,
'/MCP/MPHomePageController/getUserDetailsDisplay')
params = {'_': int(time.time() * 1000)}
user = _request(url, params=params).json()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/user/bin/env python3
# coding: utf-8

from . import constants as C
from .sap_api_common import _request
from .sap_id_sso import sap_sso_login
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



def get_software_catalog():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/user/bin/env python3
# coding: utf-8

import hashlib
import json
import logging
Expand All @@ -12,7 +9,7 @@

from . import constants as C
from .sap_api_common import _request, https_session
from .sap_id_sso import _get_sso_endpoint_meta, sap_sso_login
from .sap_id_sso import _get_sso_endpoint_meta
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from . import constants as C
from .sap_api_common import _request
from .sap_id_sso import sap_sso_login
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



def search_software_fuzzy(query, max=None, csv_filename=None):
Expand Down
3 changes: 2 additions & 1 deletion plugins/modules/maintenance_planner_files.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3

# SAP Maintenance Planner files retrieval

Expand Down Expand Up @@ -69,6 +69,7 @@
from ..module_utils.sap_launchpad_maintenance_planner_runner import *
from ..module_utils.sap_launchpad_software_center_download_runner import \
is_download_link_available
from ..module_utils.sap_id_sso import sap_sso_login
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



def run_module():
Expand Down
3 changes: 2 additions & 1 deletion plugins/modules/maintenance_planner_stack_xml_download.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3

# SAP Maintenance Planner Stack XML download

Expand Down Expand Up @@ -69,6 +69,7 @@

# Import runner
from ..module_utils.sap_launchpad_maintenance_planner_runner import *
from ..module_utils.sap_id_sso import sap_sso_login
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



def run_module():
Expand Down
3 changes: 2 additions & 1 deletion plugins/modules/software_center_download.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3

# SAP software download module

Expand Down Expand Up @@ -88,6 +88,7 @@

# Import runner
from ..module_utils.sap_launchpad_software_center_download_runner import *
from ..module_utils.sap_id_sso import sap_sso_login
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



def run_module():
Expand Down