Skip to content

Commit

Permalink
fix docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
aatrubilin committed Jul 19, 2019
1 parent 8eb2ed3 commit a25194a
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 113 deletions.
20 changes: 18 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
Changelog
=========

Version 0.63
===========
*Released 2019-07-19*

New Features

- Added :meth:`trassir_script_framework.BaseUtils.dt_to_ts`
- Added :class:`trassir_script_framework.StockScript`
- Added :meth:`trassir_script_framework.PokaYoke.fire_recognizer_events`

Changes

- Rename :meth:`trassir_script_framework.BaseUtils.ts_to_datetime` -> :meth:`trassir_script_framework.BaseUtils.dt_to_ts`
- Update TBotAPI: Fix - Send image method with cyrillic symbols on WinOS; Add - send_image_album
- Fix docstrings

Version 0.61
===========
*Released 2019-07-12*
Expand All @@ -18,7 +34,7 @@ Changes
- Rebuild :meth:`trassir_script_framework.ShotSaver.pool_shot`
- Rebuild :meth:`trassir_script_framework.BaseUtils.get_logger`

Version 0.6
Version 0.60
===========
*Released 2019-07-05*

Expand All @@ -28,7 +44,7 @@ Changes
- Update tbot_api
- Other fixes

Version 0.5
Version 0.50
===========
*Released 2019-05-16*

Expand Down
4 changes: 4 additions & 0 deletions docs/source/script_framework.poka_yoke.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ check_phones
------------
.. automethod:: trassir_script_framework.PokaYoke.check_phones

fire_recognizer_events
----------------------
.. automethod:: trassir_script_framework.PokaYoke.fire_recognizer_events

47 changes: 0 additions & 47 deletions tests/host.py

This file was deleted.

129 changes: 65 additions & 64 deletions trassir_script_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,8 +917,8 @@ def run_as_thread_v2(cls, locked=False, daemon=True):
>>>
>>> @BaseUtils.run_as_thread_v2()
>>> def run_count_timer():
>>> time.sleep(1)
>>> host.stats()["run_count"] += 1
... time.sleep(1)
... host.stats()["run_count"] += 1
>>>
>>>
>>> run_count_timer()
Expand Down Expand Up @@ -976,8 +976,8 @@ def run_as_thread(fn):
>>>
>>> @BaseUtils.run_as_thread
>>> def run_count_timer():
>>> time.sleep(1)
>>> host.stats()["run_count"] += 1
... time.sleep(1)
... host.stats()["run_count"] += 1
>>>
>>>
>>> run_count_timer()
Expand Down Expand Up @@ -1127,7 +1127,8 @@ def cat(cls, filepath, check_ext=True):
Examples:
>>> BaseUtils.cat("/home/trassir/ Trassir 3 License.txt")
.. image:: images/base_utils.cat.png
.. image:: images/base_utils.cat.png
Raises:
:class:`TypeError`: Если ``check_ext=True`` расширение файла нет в списке :obj:`_TEXT_FILE_EXTENSIONS`
Expand Down Expand Up @@ -1441,9 +1442,9 @@ def get_object(cls, obj_id):
Examples:
>>> obj = BaseUtils.get_object("EZJ4QnbC")
>>> if obj is None:
>>> host.error("Object not found")
>>> else:
>>> host.message("Object name is {0.name}".format(obj))
... host.error("Object not found")
... else:
... host.message("Object name is {0.name}".format(obj))
"""
if not isinstance(obj_id, (str, unicode)):
raise TypeError(
Expand Down Expand Up @@ -1619,10 +1620,10 @@ def get_logger(
>>> logger = BaseUtils.get_logger()
>>> logger.warning("My warning message")
>>> try:
>>> # noinspection PyUnresolvedReferences
>>> do_something()
>>> except NameError:
>>> logger.error("Function is not defined", exc_info=True)
... # noinspection PyUnresolvedReferences
... do_something()
... except NameError:
... logger.error("Function is not defined", exc_info=True)
"""
logger_ = logging.getLogger(__name__)
logger_.setLevel("DEBUG")
Expand Down Expand Up @@ -1807,9 +1808,9 @@ class HTTPRequester(py_object):
>>>
>>> requests = HTTPRequester(opener, timeout=20)
>>> response = requests.get(
>>> "https://172.20.0.101:8080/login",
>>> params={"username": "Admin", "password": "12345"}
>>> )
... "https://172.20.0.101:8080/login",
... params={"username": "Admin", "password": "12345"}
... )
>>>
>>> response.code
200
Expand Down Expand Up @@ -1889,9 +1890,9 @@ def get(self, url, params=None, headers=None):
Examples:
>>> requests = HTTPRequester()
>>> response = requests.get(
>>> "http://httpbin.org/get",
>>> params={"PARAMETER": "TEST"},
>>> )
... "http://httpbin.org/get",
... params={"PARAMETER": "TEST"},
... )
>>> response.code
200
>>> response.text
Expand Down Expand Up @@ -1922,10 +1923,10 @@ def post(self, url, data=None, headers=None):
Examples:
>>> requests = HTTPRequester()
>>> response = requests.post(
>>> "http://httpbin.org/post",
>>> data={"PARAMETER": "TEST"},
>>> headers={"Content-Type": "application/json"},
>>> )
... "http://httpbin.org/post",
... data={"PARAMETER": "TEST"},
... headers={"Content-Type": "application/json"},
... )
>>> response.code
200
>>> response.text
Expand Down Expand Up @@ -2310,14 +2311,14 @@ def async_shot(
Examples:
>>> # noinspection PyUnresolvedReferences
>>> def callback(success, shot_path):
>>> # Пример callback функции
>>> # Args:
>>> # success (bool): True если скриншот успешно сохранен, иначе False
>>> # shot_path (str): Полный путь до скриншота
>>> if success:
>>> host.message("Скриншот успешно сохранен<br>%s" % shot_path)
>>> else:
>>> host.error("Ошибка сохранения скриншота <br>%s" % shot_path)
... # Пример callback функции
... # Args:
... # success (bool): True если скриншот успешно сохранен, иначе False
... # shot_path (str): Полный путь до скриншота
... if success:
... host.message("Скриншот успешно сохранен<br>%s" % shot_path)
... else:
... host.error("Ошибка сохранения скриншота <br>%s" % shot_path)
>>>
>>> ss = ShotSaver()
>>> ss.async_shot("e80kgBLh_pV4ggECb", callback=callback)
Expand Down Expand Up @@ -2397,15 +2398,15 @@ class VideoExporter(py_object):
>>> # noinspection PyUnresolvedReferences
>>> def callback(success, file_path, channel_full_guid):
>>> # Пример callback функции
>>> # Args:
>>> # success (bool): True если видео экспортировано успешно, иначе False
>>> # file_path (str): Полный путь до видеофайла
>>> # channel_full_guid (str) : Полный guid канала
>>> if success:
>>> host.message("Экспорт успешно завершен<br>%s" % file_path)
>>> else:
>>> host.error("Ошибка экспорта<br>%s" % file_path)
... # Пример callback функции
... # Args:
... # success (bool): True если видео экспортировано успешно, иначе False
... # file_path (str): Полный путь до видеофайла
... # channel_full_guid (str) : Полный guid канала
... if success:
... host.message("Экспорт успешно завершен<br>%s" % file_path)
... else:
... host.error("Ошибка экспорта<br>%s" % file_path)
>>> ss = VideoExporter()
>>> dt_start = datetime.now() - timedelta(seconds=120)
Expand Down Expand Up @@ -2688,7 +2689,7 @@ class GUITemplate(py_object):
Examples:
>>> # Создаем шаблон с именем "New template" и получаем его guid
>>> template = Template("New template")
>>> template = GUITemplate("New template")
>>> template.guid
'Y2YFAkeZ'
Expand Down Expand Up @@ -3210,11 +3211,11 @@ class Channels(ObjectFromSetting):
>>>
>>> # Включим ручную запись на выбранных каналах
>>> for channel in selected_channels:
>>> channel.obj.manual_record_start()
... channel.obj.manual_record_start()
>>>
>>> # Или добавим к имени канала его guid
>>> for channel in selected_channels:
>>> channel.settings["name"] += " ({})".format(channel.guid)
... channel.settings["name"] += " ({})".format(channel.guid)
"""

def __init__(self, server_guid=None):
Expand Down Expand Up @@ -3328,7 +3329,7 @@ class Devices(ObjectFromSetting):
>>>
>>> # Перезагрузим все устройства
>>> for dev in enabled_devices:
>>> dev.settings["reboot"] = 1
... dev.settings["reboot"] = 1
"""

def __init__(self, server_guid=None):
Expand Down Expand Up @@ -3429,7 +3430,7 @@ class Scripts(ObjectFromSetting):
>>>
>>> # Отключим все скрипты
>>> for script in all_scripts:
>>> script.settings["enable"] = 0
... script.settings["enable"] = 0
"""

def __init__(self, server_guid=None):
Expand Down Expand Up @@ -3526,7 +3527,7 @@ class StockScripts(ObjectFromSetting):
>>>
>>> # Отключим все скрипты
>>> for script in all_scripts:
>>> script.settings["enable"] = 0
... script.settings["enable"] = 0
"""

def __init__(self, server_guid=None):
Expand Down Expand Up @@ -3627,7 +3628,7 @@ class Rules(ObjectFromSetting):
>>>
>>> # Отключим все правила
>>> for rule in all_rules:
>>> rule.settings["enable"] = 0
... rule.settings["enable"] = 0
"""

def __init__(self, server_guid=None):
Expand Down Expand Up @@ -3753,11 +3754,11 @@ def on_load(self, schedule_name, callback, tries=5):
>>> schedule = None
>>> # noinspection PyGlobalUndefined,PyUnresolvedReferences
>>> def on_schedule_loaded(schedule_obj):
>>> global schedule
>>> schedule = schedule_obj
>>>
>>> message("Schedule '{obj.name}' ({obj.guid}) loaded".format(obj=schedule))
>>> schedule.activate_on_state_changes(lambda: alert(schedule.state("color")))
... global schedule
... schedule = schedule_obj
...
... message("Schedule '{obj.name}' ({obj.guid}) loaded".format(obj=schedule))
... schedule.activate_on_state_changes(lambda: alert(schedule.state("color")))
>>>
>>> Schedules().on_load("Unnamed Schedule", on_schedule_loaded)
"""
Expand Down Expand Up @@ -4652,7 +4653,7 @@ def _zone_type(self, zone_obj):
"not a workplace"

try:
zones_dir = settings("/%s/channels/%s/deep_people" % (server, channel))
zones_dir = self._host_api.settings("/%s/channels/%s/deep_people" % (server, channel))
for i in xrange(16):
if zones_dir["zone%02d_guid" % i] == guid:
if zones_dir["zone%02d_type" % i] in ["border", "border_swapped"]:
Expand Down Expand Up @@ -5913,18 +5914,18 @@ class FTPSender(Sender):
Examples:
>>> # noinspection PyUnresolvedReferences
>>> def callback(file_path, progress, error):
>>> # Пример callback функции, которая отображает
>>> # текущий прогресс в счетчике запуска скрипта
>>> # Args:
>>> # file_path (str): Путь до файла
>>> # progress (int): Текущий прогресс передачи файла, %
>>> # error (str | Exception): Ошибка при отправке файла, если есть
>>> host.stats()["run_count"] = progress
>>> if error:
>>> host.error(error)
>>>
>>> if progress == 100:
>>> host.timeout(3000, lambda: os.remove(BaseUtils.win_encode_path(file_path)))
... # Пример callback функции, которая отображает
... # текущий прогресс в счетчике запуска скрипта
... # Args:
... # file_path (str): Путь до файла
... # progress (int): Текущий прогресс передачи файла, %
... # error (str | Exception): Ошибка при отправке файла, если есть
... host.stats()["run_count"] = progress
... if error:
... host.error(error)
...
... if progress == 100:
... host.timeout(3000, lambda: os.remove(BaseUtils.win_encode_path(file_path)))
>>>
>>> sender = FTPSender("172.20.0.10", 21, "trassir", "12345", work_dir="/test_dir/", callback=callback)
>>> sender.files(r"D:\Shots\export_video.avi")
Expand Down

0 comments on commit a25194a

Please sign in to comment.