halib 0.1.27__py3-none-any.whl → 0.1.29__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
halib/tele_noti.py CHANGED
@@ -70,6 +70,8 @@ def df2img(df: pd.DataFrame, output_img_dir, decimal_places, out_img_scale):
70
70
  )
71
71
  )
72
72
  ])
73
+ if not os.path.exists(output_img_dir):
74
+ os.makedirs(output_img_dir)
73
75
  img_path = os.path.normpath(os.path.join(output_img_dir, "last_lines.png"))
74
76
  fig.write_image(img_path, scale=out_img_scale)
75
77
  return img_path
@@ -80,7 +82,11 @@ def compose_message_and_img_path(
80
82
  ):
81
83
  context_msg = f">> Project: {project} \n>> File: {target_file} \n>> Last {num_last_lines} lines:"
82
84
  msg_df = get_watcher_message_df(target_file, num_last_lines)
83
- img_path = df2img(msg_df, output_img_dir, decimal_places, out_img_scale)
85
+ try:
86
+ img_path = df2img(msg_df, output_img_dir, decimal_places, out_img_scale)
87
+ except Exception as e:
88
+ pprint(f"Error: {e}")
89
+ img_path = None
84
90
  return context_msg, img_path
85
91
 
86
92
 
@@ -99,17 +105,22 @@ async def send_to_telegram(cfg_dict):
99
105
 
100
106
  bot = telegram.Bot(token=token)
101
107
  async with bot:
102
- context_msg, img_path = compose_message_and_img_path(
103
- target_file,
104
- project,
105
- num_last_lines,
106
- decimal_places,
107
- out_img_scale,
108
- output_img_dir,
109
- )
110
- pprint('Sending message to telegram...')
111
- await bot.send_message(text=context_msg, chat_id=chat_id)
112
- await bot.send_photo(chat_id=chat_id, photo=open(img_path, "rb"))
108
+ try:
109
+ context_msg, img_path = compose_message_and_img_path(
110
+ target_file,
111
+ project,
112
+ num_last_lines,
113
+ decimal_places,
114
+ out_img_scale,
115
+ output_img_dir,
116
+ )
117
+ pprint('Sending message to telegram...')
118
+ await bot.send_message(text=context_msg, chat_id=chat_id)
119
+ if img_path:
120
+ await bot.send_photo(chat_id=chat_id, photo=open(img_path, "rb"))
121
+ except Exception as e:
122
+ pprint(f'Error: {e}')
123
+ pprint('Message not sent to telegram')
113
124
 
114
125
 
115
126
  async def run_forever(cfg_path):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: halib
3
- Version: 0.1.27
3
+ Version: 0.1.29
4
4
  Summary: Small library for common tasks
5
5
  Author: Hoang Van Ha
6
6
  Author-email: hoangvanhauit@gmail.com
@@ -25,9 +25,14 @@ Requires-Dist: moviepy
25
25
  Requires-Dist: tube-dl
26
26
  Requires-Dist: enlighten
27
27
  Requires-Dist: pycurl
28
+ Requires-Dist: kaleido (==0.1.*)
28
29
 
29
30
  Helper package for coding and automation
30
31
 
32
+ **Version 0.1.29**
33
+
34
+ + for `tele_noti` module, `kaleido==0.1.*` is required for plotly since `kaleido 0.2.*` is not working (taking for ever to generate image)
35
+ ---
31
36
  **Version 0.1.24**
32
37
 
33
38
  + rename `sys` to `system` to avoid conflict with built-in `sys` module
@@ -9,7 +9,7 @@ halib/jsonfile.py,sha256=9XfdFS1wcTdBRmpAGzVu2dVCcJp8RCpsSY16f6KUNts,480
9
9
  halib/listop.py,sha256=Vpa8_2fI0wySpB2-8sfTBkyi_A4FhoFVVvFiuvW8N64,339
10
10
  halib/plot.py,sha256=drLaHL_JVnIeFxsgYYXepJHIECzOmRImX40cWPJJshs,475
11
11
  halib/projectmake.py,sha256=8dNTxB2jgQlwvovaOnJcCKgHe5vM0nBwzm46Yc8INEI,4048
12
- halib/tele_noti.py,sha256=lM9lk__LBv4O0mqnp-hBFDUtiE4KHiOdo9C0Z4pt1Oo,4765
12
+ halib/tele_noti.py,sha256=ylWW8iNYMxXY0n0aGjy3UwpId-BcExexxMzS3KGNZn4,5151
13
13
  halib/textfile.py,sha256=EhVFrit-nRBJx18e6rtIqcE1cSbgsLnMXe_kdhi1EPI,399
14
14
  halib/videofile.py,sha256=NTLTZ-j6YD47duw2LN2p-lDQDglYFP1LpEU_0gzHLdI,4737
15
15
  halib/filetype/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -29,8 +29,8 @@ halib/sys/filesys.py,sha256=ERpnELLDKJoTIIKf-AajgkY62nID4qmqmX5TkE95APU,2931
29
29
  halib/system/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  halib/system/cmd.py,sha256=b2x7JPcNnFjLGheIESVYvqAb-w2UwBM1PAwYxMZ5YjA,228
31
31
  halib/system/filesys.py,sha256=ERpnELLDKJoTIIKf-AajgkY62nID4qmqmX5TkE95APU,2931
32
- halib-0.1.27.dist-info/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
33
- halib-0.1.27.dist-info/METADATA,sha256=GpkSZbox6Job_VDmtK24_SL8-NsXZXSPBHs65-L49LQ,2264
34
- halib-0.1.27.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
35
- halib-0.1.27.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
36
- halib-0.1.27.dist-info/RECORD,,
32
+ halib-0.1.29.dist-info/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
33
+ halib-0.1.29.dist-info/METADATA,sha256=68encJ7pD7CaK9IGSFENLwGijVfWP_ZB0uBSD4cMe2g,2460
34
+ halib-0.1.29.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
35
+ halib-0.1.29.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
36
+ halib-0.1.29.dist-info/RECORD,,
File without changes