Skip to content

Commit

Permalink
iCloud3 v3, Release Candidate 1
Browse files Browse the repository at this point in the history
  • Loading branch information
gcobb321 committed Aug 6, 2023
1 parent 079b5ef commit 683fd02
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
1 change: 1 addition & 0 deletions custom_components/icloud3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
43 changes: 43 additions & 0 deletions custom_components/icloud3/services.yaml
Original file line number Diff line number Diff line change
@@ -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
45 changes: 44 additions & 1 deletion custom_components/icloud3/support/config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,4 +551,47 @@ def build_initial_config_file_structure():
pass


#--------------------------------------------------------------------:)
#--------------------------------------------------------------------
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

0 comments on commit 683fd02

Please sign in to comment.