def create_usage_excel(self, record_data):
            # type: ([UsageData]) -> str
            # Creates the Excel .xlsx File and loads the records returning the file path
            excel_records = Usage.UsageFileExcelCreator._load_records(
                record_data)
            workbook = self._create_usage_records_sheet(records=excel_records)

            # Saves the file in the .config folder
            config_file = Utils.get_config_file()
            usage_path = config_file['rootPathUsage']
            if not os.path.exists(usage_path):
                os.mkdir(usage_path)
            path = usage_path + "/usage_file" + datetime.today().strftime(
                "%Y%m%d%H%M%S") + ".xlsx"
            workbook.save(path)
            return path
Esempio n. 2
0
from cnct import ConnectClient
from datetime import datetime
from connect_processor.app.utils.globals import Globals
from connect_processor.app.utils.utils import Utils
from cnct import R

project_manager = __import__('connect_processor.app', globals(), locals(), [
    'purchase', 'change', 'cancel', 'suspend', 'resume', 'tier_fulfillment',
    'report_usage'
], 0)

# The processor.py is the entry point of Processor execution
if __name__ == '__main__':

    # Reading the config.json file in the Processor
    config_file = Utils.get_config_file()
    # apiEndpoint is the API End-point of Connect
    connect_api_url = config_file['connectApiEndpoint'],
    # apiKey is the API key for authorization created in Integrations menu of Connect
    connect_key = config_file['connectApiKey'],
    # Products are the list of IDs of the products which needs to be processed by this Processor
    client = ConnectClient(api_key=connect_key[0], endpoint=connect_api_url[0])

    # If the Product has parameters of scope 'Tier' then Tier use case implementation will be required.
    # Make sure the project has the Tier use case included during project creation
    # The Tier Config Requests (TCR) needs to be processed first and then the corresponding Fulfillment Requests
    if hasattr(project_manager, 'tier_fulfillment'):
        # Filter to fetch the Tier-Config-Request (TCR) for this product
        # The processor needs to process only the TCRs in Pending status

        query_tcr = R()