From 683fd02bde55ab1df1c79fd92f9e36b71293b3cc Mon Sep 17 00:00:00 2001 From: gcobb321 Date: Sun, 6 Aug 2023 16:31:08 -0400 Subject: [PATCH] iCloud3 v3, Release Candidate 1 --- custom_components/icloud3/__init__.py | 1 + custom_components/icloud3/services.yaml | 43 ++++++++++++++++++ .../icloud3/support/config_file.py | 45 ++++++++++++++++++- 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 custom_components/icloud3/services.yaml diff --git a/custom_components/icloud3/__init__.py b/custom_components/icloud3/__init__.py index ced51ac..9c86ba6 100644 --- a/custom_components/icloud3/__init__.py +++ b/custom_components/icloud3/__init__.py @@ -130,6 +130,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): config_file.load_storage_icloud3_configuration_file() start_ic3.set_log_level(Gb.log_level) open_ic3_log_file(new_log_file=Gb.log_debug_flag) + # config_file.count_lines_of_code(Gb.icloud3_directory) Gb.evlog_btnconfig_url = Gb.conf_profile[CONF_EVLOG_BTNCONFIG_URL].strip() Gb.evlog_version = Gb.conf_profile['event_log_version'] diff --git a/custom_components/icloud3/services.yaml b/custom_components/icloud3/services.yaml new file mode 100644 index 0000000..f7fff6c --- /dev/null +++ b/custom_components/icloud3/services.yaml @@ -0,0 +1,43 @@ +# yamllint disable rule:document-start +# yamllint disable rule:line-length + +icloud3_action: + description: This service allows you to change the way iCloud3 operates. + fields: + device_name: + description: Name of the device to be updated. All devices will be updated if this parameter is not specified. (Optional) + example: gary_iphone + command: + description: The action to be performed. (Required) + example: log_level debug + +icloud3_update: + description: This service allows you to change the way iCloud3 operates. + fields: + device_name: + description: Name of the device to be updated. All devices will be updated if this parameter is not specified. (Optional) + example: gary_iphone + command: + description: The action to be performed. (Required) + example: log_level debug + +icloud3_restart: + description: This service will refresh all of the devices being handled by iCloud3 and can be used when you have added a new device to your Apple account. You will have to restart Home Assist if you have made changes to the platform parameters (new device type, new device name, etc.) + fields: + account_name: + description: account_name of the iCloud3 custom component specified in the Configuration Variables section described at the beginning of this document. (Required) + example: gary_icloud + +icloud3_lost_iphone: + description: This service will play the Lost iPhone sound on a specific device. + fields: + device_name: + description: Name of the device to be located (required). + example: gary_icloud + +icloud3_find_phone_alert: + description: This service will send a find phone message to the specific device. + fields: + device_name: + description: Name of the device to be located (required). + example: gary_icloud diff --git a/custom_components/icloud3/support/config_file.py b/custom_components/icloud3/support/config_file.py index 765f7a8..f1cc45c 100644 --- a/custom_components/icloud3/support/config_file.py +++ b/custom_components/icloud3/support/config_file.py @@ -551,4 +551,47 @@ def build_initial_config_file_structure(): pass -#--------------------------------------------------------------------:) \ No newline at end of file +#-------------------------------------------------------------------- +def count_lines_of_code(start_directory, total_file_lines=0, total_code_lines=0, begin_start=None): + + if begin_start is None: + log_info_msg(f"Lines Of Code Count - {start_directory}") + log_info_msg(" ") + log_info_msg("---All Lines--- ---Code Lines--- Module") + log_info_msg("Total Lines Total Lines") + # ("11111111 22222222 33333333 44444444 + + for file_name in os.listdir(start_directory): + file_name = os.path.join(start_directory, file_name) + if os.path.isfile(file_name): + if file_name.endswith('.py') or file_name.endswith('.js'): + with open(file_name, 'r') as f: + lines = f.readlines() + line_cnt = len(lines) + total_file_lines += line_cnt + code_cnt = 0 + for line in lines: + if line is not None and len(line.strip()) > 3: + if (line.startswith("'") + or line.startswith('#')): + continue + + code_cnt += 1 + + total_code_lines += code_cnt + + if begin_start is not None: + reldir_of_file_name = '.' + file_name.replace(begin_start, '') + else: + reldir_of_file_name = '.' + file_name.replace(start_directory, '') + + log_info_msg( f"{total_file_lines:<9} {line_cnt:<9} {total_code_lines:<9} " + f"{code_cnt:<8} {reldir_of_file_name}") + + for file_name in os.listdir(start_directory): + file_name = os.path.join(start_directory, file_name) + if os.path.isdir(file_name): + total_file_lines, total_code_lines = \ + count_lines_of_code(file_name, total_file_lines, total_code_lines, begin_start=start_directory) + + return total_file_lines, total_code_lines \ No newline at end of file