HackaProfile 1.1.0__tar.gz → 1.2.0__tar.gz

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.
Files changed (21) hide show
  1. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/HackaProfile.egg-info/PKG-INFO +1 -1
  2. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/PKG-INFO +1 -1
  3. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/pyproject.toml +1 -1
  4. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/agent.py +15 -9
  5. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/frontend.py +86 -81
  6. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/HackaProfile.egg-info/SOURCES.txt +0 -0
  7. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/HackaProfile.egg-info/dependency_links.txt +0 -0
  8. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/HackaProfile.egg-info/entry_points.txt +0 -0
  9. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/HackaProfile.egg-info/requires.txt +0 -0
  10. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/HackaProfile.egg-info/top_level.txt +0 -0
  11. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/README.md +0 -0
  12. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/setup.cfg +0 -0
  13. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/__init__.py +0 -0
  14. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/backend.py +0 -0
  15. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/configTemplate/agent.pid +0 -0
  16. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/configTemplate/hackaprofile.conf +0 -0
  17. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/configTemplate/hackatime.hackaprofile.conf +0 -0
  18. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/configTemplate/slack.hackaprofile.conf +0 -0
  19. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/hackatimeOA.py +0 -0
  20. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/logTemplate/agent.log +0 -0
  21. {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/slackOA.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: HackaProfile
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: A simple tool to automatically update Slack user profile based on their Hackatime/Wakatime heartbeat!
5
5
  Project-URL: Repository, https://github.com/zibuyin/HackaProfile
6
6
  Project-URL: Issues, https://github.com/zibuyin/HackaProfile/issues
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: HackaProfile
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: A simple tool to automatically update Slack user profile based on their Hackatime/Wakatime heartbeat!
5
5
  Project-URL: Repository, https://github.com/zibuyin/HackaProfile
6
6
  Project-URL: Issues, https://github.com/zibuyin/HackaProfile/issues
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "HackaProfile"
7
- version = "1.1.0"
7
+ version = "1.2.0"
8
8
  description = "A simple tool to automatically update Slack user profile based on their Hackatime/Wakatime heartbeat!"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -8,14 +8,20 @@ import os
8
8
  from pathlib import Path
9
9
  import platformdirs
10
10
  from jinja2 import Template
11
+ import logging
11
12
 
12
- print("***** WORKER AGENT STARTER *****")
13
+ logging.basicConfig(
14
+ format='[%(asctime)s] (Line: %(lineno)d) %(message)s',
15
+ level=logging.INFO
16
+ )
17
+
18
+ print("***** WORKER AGENT STARTED *****")
13
19
  hackatime = backend.hackatime()
14
20
  slack = backend.slack()
15
21
 
16
22
 
17
23
  active_services = ["slack"]
18
- interval = 20
24
+ interval = 10
19
25
  HOME = Path.home()
20
26
  CONFIG_DIR = Path(platformdirs.user_config_dir("hackaprofile"))
21
27
  LOG_DIR = Path(platformdirs.user_log_dir("hackaprofile"))
@@ -48,9 +54,9 @@ def parse_config(config: dict, map):
48
54
  parsed_config[key] = result
49
55
 
50
56
  # print(parsed)
51
- print("===")
52
- print(parsed_config)
53
- print("===")
57
+ print("---Parsed Config---")
58
+ logging.info(parsed_config)
59
+ print("---EO Parsed Config---\n")
54
60
  return parsed_config
55
61
 
56
62
 
@@ -81,14 +87,14 @@ while True:
81
87
 
82
88
  print(f'Language: {map["language"]}')
83
89
  print("---HT HB---")
84
- print(json)
85
- print("---EO HT HB---")
90
+ logging.info(json)
91
+ print("---EO HT HB---\n")
86
92
  if "slack" in active_services:
87
93
  print(slack.fetch_config())
88
94
  config = parse_config(slack.fetch_config(), map)
89
95
  print(config)
90
96
 
91
97
  res = slack.set_profile(config)
92
- print(res)
93
- print("---")
98
+ logging.info(res)
99
+ print("==============================================================")
94
100
  time.sleep(interval)
@@ -33,6 +33,7 @@ import sys
33
33
  import psutil
34
34
  import signal
35
35
  import platformdirs
36
+ import shlex
36
37
 
37
38
  console = Console()
38
39
 
@@ -136,82 +137,86 @@ def setup(force: Annotated[bool, typer.Option("--force")] = False):
136
137
  """
137
138
  Guided setup of HackaProfile
138
139
  """
139
- console.clear()
140
- # console.rule("HackaProfile")
141
- rprint(Panel(Text("Welcome to HackaProfile\nyou will be guided on an easy setup of the tool!", justify="center")))
142
- console.rule()
143
- # rprint(force)
144
-
145
- # Copy log files
146
- try:
147
- # Allow overwrite if set to force
148
- shutil.copytree(Path(__file__).resolve().parent / "logTemplate", LOG_DIR, dirs_exist_ok=force)
149
- rprint("[bold green]✓[/bold green] Log file setup done!")
150
- except FileExistsError:
151
- rprint("[bold green]✓[/bold green] Log file already exists!")
152
- except Exception as e:
153
- rprint(f"❌ Failed to setup log files: {e}")
154
-
155
- # Copy config files
156
- try:
157
- # Allow overwrite if set to force
158
- shutil.copytree(Path(__file__).resolve().parent / "configTemplate", CONFIG_DIR, dirs_exist_ok=force)
159
- rprint("[bold green]✓[/bold green] Config file setup done!")
160
- except FileExistsError:
161
- rprint("[bold green]✓[/bold green] Config file already exists!")
162
- except Exception as e:
163
- rprint(f"❌ Failed to setup config files: {e}")
164
-
165
-
166
- # If no token stored
167
- if force or not hackatime.status()["ok"]:
168
- # hackatimeConfirm = Confirm.ask("[bold cyan]Do you want to authorize Hackatime (This will redirect you to OAuth page)", default=True)
169
- hackatimeConfirm = questionary.confirm("Do you want to authorize Hackatime (This will redirect you to OAuth page)").ask()
170
- if hackatimeConfirm:
171
- with console.status("Authorizing Hackatime", spinner="dots"):
172
- ok, hackatime_token = hackatime.authorize()
140
+ if force:
141
+ conf = Confirm.ask("[bold red]Setting --force will CLEAR ALL EXISTING CONFIG AND LOGS. Do you wish to continue?", default=False)
142
+ if conf:
143
+ console.clear()
144
+ # console.rule("HackaProfile")
145
+ rprint(Panel(Text("Welcome to HackaProfile\nyou will be guided on an easy setup of the tool!", justify="center")))
146
+ console.rule()
147
+ # rprint(force)
148
+
149
+ # Copy log files
150
+ try:
151
+ # Allow overwrite if set to force
152
+ shutil.copytree(Path(__file__).resolve().parent / "logTemplate", LOG_DIR, dirs_exist_ok=force)
153
+ rprint("[bold green]✓[/bold green] Log file setup done!")
154
+ except FileExistsError:
155
+ rprint("[bold green]✓[/bold green] Log file already exists!")
156
+ except Exception as e:
157
+ rprint(f"❌ Failed to setup log files: {e}")
173
158
 
174
- if ok:
175
- rprint("[bold green]✓[/bold green] Hackatime authorized!")
176
-
177
- else :
178
- rprint(f"[bold red]err: {str(hackatime_token)}")
179
- else:
180
- rprint("[bold red]err: HackaProfile could not function without Hackatime.")
181
- typer.Abort()
182
- # If already stored
183
- else:
184
- rprint("[bold green]✓[/bold green] Hackatime already authorized!\n")
185
-
186
- platforms = questionary.checkbox(
187
- message="Please choose the platforms you want to link to",
188
- choices=[
189
- "Slack",
190
- "Github"
191
- ]
192
- ).ask()
193
-
194
- # Authorize the platforms
195
-
196
- for platform in platforms:
197
- # print("test")
198
- cls = backend.platfroms.get(platform.lower())
199
- if cls:
200
- instance = cls()
201
- with console.status(f"Authorizing {platform}", spinner="dots"):
202
- ok, platform_token = instance.authorize()
203
- if ok:
204
- rprint(f"[bold green]✓[/bold green] {platform} authorized!")
159
+ # Copy config files
160
+ try:
161
+ # Allow overwrite if set to force
162
+ shutil.copytree(Path(__file__).resolve().parent / "configTemplate", CONFIG_DIR, dirs_exist_ok=force)
163
+ rprint("[bold green]✓[/bold green] Config file setup done!")
164
+ except FileExistsError:
165
+ rprint("[bold green]✓[/bold green] Config file already exists!")
166
+ except Exception as e:
167
+ rprint(f"❌ Failed to setup config files: {e}")
205
168
 
169
+
170
+ # If no token stored
171
+ if force or not hackatime.status()["ok"]:
172
+ # hackatimeConfirm = Confirm.ask("[bold cyan]Do you want to authorize Hackatime (This will redirect you to OAuth page)", default=True)
173
+ hackatimeConfirm = questionary.confirm("Do you want to authorize Hackatime (This will redirect you to OAuth page)").ask()
174
+ if hackatimeConfirm:
175
+ with console.status("Authorizing Hackatime", spinner="dots"):
176
+ ok, hackatime_token = hackatime.authorize()
177
+
178
+ if ok:
179
+ rprint("[bold green]✓[/bold green] Hackatime authorized!")
180
+
181
+ else :
182
+ rprint(f"[bold red]err: {str(hackatime_token)}")
183
+ else:
184
+ rprint("[bold red]err: HackaProfile could not function without Hackatime.")
185
+ typer.Abort()
186
+ # If already stored
206
187
  else:
207
- rprint(f"[bold red]err: {str(platform_token)}")
188
+ rprint("[bold green]✓[/bold green] Hackatime already authorized!\n")
189
+
190
+ platforms = questionary.checkbox(
191
+ message="Please choose the platforms you want to link to",
192
+ choices=[
193
+ "Slack"
194
+ ]
195
+ ).ask()
196
+
197
+ # Authorize the platforms
208
198
 
199
+ for platform in platforms:
200
+ # print("test")
201
+ cls = backend.platfroms.get(platform.lower())
202
+ if cls:
203
+ instance = cls()
204
+ with console.status(f"Authorizing {platform}", spinner="dots"):
205
+ ok, platform_token = instance.authorize()
206
+ if ok:
207
+ rprint(f"[bold green]✓[/bold green] {platform} authorized!")
208
+
209
+ else:
210
+ rprint(f"[bold red]err: {str(platform_token)}")
211
+
212
+ else:
213
+ rprint("[bold red]err: Platform unsupported")
214
+
215
+
216
+ rprint("[bold green]✓[/bold green] Setup complete!\n\n1.Run [bold green]hackaprofile config \\[platform name(e.g. slack)][/bold green] to configure\n2.Run [bold green]hackaprofile start[/bold green] to start updating your profile automatically!")
209
217
  else:
210
- rprint("[bold red]err: Platform unsupported")
211
-
212
-
213
- rprint("[bold green]✓[/bold green] Setup complete!\n\n1.Run [bold green]hackaprofile config \\[platform name][/bold green] to configure\n2.Run [bold green]hackaprofile start[/bold green] to start updating your profile automatically!")
214
-
218
+ rprint("[bold red]Aborted.")
219
+
215
220
  class placeholderHighlighter(Highlighter):
216
221
  def highlight(self, text) -> None:
217
222
  text.highlight_regex(r"\{\{.*?\}\}", "bold yellow")
@@ -221,7 +226,7 @@ def config(platform: Annotated[str, typer.Argument]):
221
226
  """
222
227
  Shows a structured preview of the config files for each of the platforms
223
228
  """
224
-
229
+ rprint("[bold red]Check README.md on how to configure HackaProfile!\n")
225
230
  table = Table(
226
231
  "Field",
227
232
  "Value",
@@ -254,16 +259,16 @@ def config(platform: Annotated[str, typer.Argument]):
254
259
  if option == "Exit":
255
260
  typer.Exit()
256
261
  elif option == "Edit":
257
- path = str(CONFIG_DIR/ f"{platform}.hackaprofile.conf")
258
- rprint(f"\n[bold green]Open[/bold green] {path} [bold green]in your preferred editor!")
262
+ path = shlex.quote(str(CONFIG_DIR/ f"{platform}.hackaprofile.conf"))
263
+ rprint(f"\n[bold cyan]Open[/bold cyan] {path} [bold cyan]in your preferred editor!")
259
264
 
260
- cbConfirm = questionary.confirm(
261
- "Do you want to copy path to clipboard?",
262
- default=False
263
- ).ask()
264
- if cbConfirm:
265
- pyperclip.copy(path)
266
- rprint("[bold green]✓[/bold green] Copied!")
265
+ # cbConfirm = questionary.confirm(
266
+ # "Do you want to copy path to clipboard?",
267
+ # default=False
268
+ # ).ask()
269
+ # if cbConfirm:
270
+ # pyperclip.copy(path)
271
+ # rprint("[bold green]✓[/bold green] Copied!")
267
272
 
268
273
  # with Live(table, refresh_per_second=4):
269
274
  # console.clear()Path(__file__).resolve().parent.parent / "config" / f"{platform}.hackaprofile.conf"
File without changes
File without changes