Skip to content

Commit

Permalink
remove all references to "profile"
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Voigt committed Nov 27, 2024
1 parent 5654dc4 commit d26b470
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 193 deletions.
4 changes: 2 additions & 2 deletions simulators/extras/ArgumentsAndCredentialsHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def SetupLogger(console_logger_name, console_log_level):


def HandleExportArguments():
parser = argparse.ArgumentParser(description='Script to export or import profiles data')
parser = argparse.ArgumentParser(description='Script to export or import data')
export_arg = parser.add_argument_group('Import')
export_arg.add_argument('--device-ids', '-i', type=str, help='Input device id / List of device ids', nargs='+')
export_arg.add_argument('--create-from', '-from', type=str, help='Input "create from" milestone')
Expand Down Expand Up @@ -118,7 +118,7 @@ def HandleExportArguments():


def HandleImportArguments():
parser = argparse.ArgumentParser(description='Script to import profiles data')
parser = argparse.ArgumentParser(description='Script to import data')

import_arg = parser.add_argument_group('Import')
import_arg.add_argument('--ifiles', '-i', type=str, help='Input file', nargs='+')
Expand Down
16 changes: 8 additions & 8 deletions simulators/extras/ExportData.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Setup Log
file_log_level = logging.DEBUG
console_log_level = LOG_LEVEL
consoleLogger = ArgumentsAndCredentialsHandler.SetupLogger(console_logger_name='ConsoleExportProfileData', console_log_level=console_log_level)
consoleLogger = ArgumentsAndCredentialsHandler.SetupLogger(console_logger_name='ConsoleExportData', console_log_level=console_log_level)
#####################################################

session = requests.Session()
Expand All @@ -31,7 +31,7 @@
######################################################


def ExportAllProfileDataFromChildDevices(createFrom, createTo):
def ExportAllDataFromChildDevices(createFrom, createTo):
deviceInTenantCount = 0
childDeviceCount = 0
deviceManagedObject = c8y.device_inventory.select(type=C8Y_OEE_SIMULATOR_DEVICES_GROUP)
Expand All @@ -42,21 +42,21 @@ def ExportAllProfileDataFromChildDevices(createFrom, createTo):
childDeviceCount += len(device.child_devices)
consoleLogger.info(f"List {len(device.child_devices)} of {device.name}'s child devices: ")
for childDevice in device.child_devices:
ExportSpecificProfileDataWithDeviceId(createFrom=createFrom,createTo=createTo, deviceId=childDevice.id)
ExportSpecificDataWithDeviceId(createFrom=createFrom, createTo=createTo, deviceId=childDevice.id)

if deviceInTenantCount == 0:
consoleLogger.info(f"No device in tenant {c8y.tenant_id} found")
else:
consoleLogger.info(f"There are {deviceInTenantCount} devices with {childDeviceCount} child devices in total")


def ExportSpecificProfileDataWithDeviceId(createFrom, createTo, deviceId):
def ExportSpecificDataWithDeviceId(createFrom, createTo, deviceId):
deviceName = FindDeviceNameById(deviceId, c8y.base_url)
consoleLogger.info(f"Child device {deviceName}, id #{deviceId}")
deviceExternalId, deviceExternalIdType = CheckDeviceExternalIdById(deviceId, c8y.base_url)
if not deviceExternalId:
return
if IsExternalIdTypeEventBasedSimulatorProfile(deviceExternalIdType):
if IsExternalIdTypeEventBasedSimulator(deviceExternalIdType):
filePath = CreateFilePath(Id=deviceExternalId)
else:
return
Expand Down Expand Up @@ -153,7 +153,7 @@ def CheckDeviceExternalIdById(deviceId, baseUrl):
return deviceExternalId, deviceExternalIdType


def IsExternalIdTypeEventBasedSimulatorProfile(deviceExternalIdType):
def IsExternalIdTypeEventBasedSimulator(deviceExternalIdType):
if deviceExternalIdType == C8Y_OEE_SIMULATOR_DEVICES_GROUP:
return True
else:
Expand Down Expand Up @@ -213,7 +213,7 @@ def SetTimePeriodToExportData():
consoleLogger.info(f"and created before/to: {createTo}")

if not DEVICE_ID_LIST:
ExportAllProfileDataFromChildDevices(createFrom=createFrom, createTo=createTo)
ExportAllDataFromChildDevices(createFrom=createFrom, createTo=createTo)
else:
for deviceId in DEVICE_ID_LIST:
ExportSpecificProfileDataWithDeviceId(createFrom=createFrom, createTo=createTo, deviceId=deviceId)
ExportSpecificDataWithDeviceId(createFrom=createFrom, createTo=createTo, deviceId=deviceId)
2 changes: 1 addition & 1 deletion simulators/extras/ImportData.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
C8Y_HEADERS, MEASUREMENTS_HEADERS = ArgumentsAndCredentialsHandler.SetupHeadersForAPIRequest(tenant_id=c8y.tenant_id, username= c8y.username, password=password)
####################################################
# Setup Log
consoleLogger = ArgumentsAndCredentialsHandler.SetupLogger(console_logger_name='ConsoleImportProfileData', console_log_level=console_log_level)
consoleLogger = ArgumentsAndCredentialsHandler.SetupLogger(console_logger_name='ConsoleImportData', console_log_level=console_log_level)
#####################################################

session = requests.Session()
Expand Down
4 changes: 2 additions & 2 deletions simulators/extras/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generic scripts information
This scripts folder contains:
- The [Export Script](./ExportOrImportProfileData.py) can be used to export a json file for any managed object. This json file can then be used for the import.
- The [Export Script](./ExportData.py) can be used to export a json file for any managed object. This json file can then be used for the import.
- The [Environment File](./Environment.py) is used to set up environment parameters.
- The [Import Script](./ImportData.py) can be used to import alarms and measurements into cumulocity.
- The [Import Script](./ImportData.py) can be used to import alarms and measurements into Cumulocity IoT.

## Setup environment parameters:
Input necessary configuration in **Environment.py** file\
Expand Down
4 changes: 2 additions & 2 deletions test/export_import_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def setUp(self):
}

@patch('logging.Logger.error')
def test_export_import_profile_data(self, mock_error):
def test_export_import_data(self, mock_error):
# Get current working directory
current_dir = os.getcwd()
# Extracts the base name of the current directory
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_export_import_profile_data(self, mock_error):
finally:
# Change back to the original working directory
os.chdir(current_dir)
# Delete test device and profile
# Delete test device
Utils.delete_device(self=self, device_id=device_id)

class Utilities:
Expand Down
88 changes: 0 additions & 88 deletions test/profile_templates/sim_001_test_profile.template

This file was deleted.

88 changes: 0 additions & 88 deletions test/profile_templates/sim_002_test_profile.template

This file was deleted.

4 changes: 2 additions & 2 deletions test/simulators_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ def test_run_simulators_script(self):
# Terminate the script
process.terminate()

# Get event device id and profile id from device external id
# Get event device id from device external id
event_device_id = Utils.get_device_id_from_external_id(self, self.device_model_with_events.get('id'))
# Get measurement device id and profile id from device external id
# Get measurement device id from device external id
measurement_device_id = Utils.get_device_id_from_external_id(self, self.device_model_with_measurements.get('id'))

# TODO! get some dates!
Expand Down

0 comments on commit d26b470

Please sign in to comment.