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.
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/HackaProfile.egg-info/PKG-INFO +1 -1
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/PKG-INFO +1 -1
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/pyproject.toml +1 -1
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/agent.py +15 -9
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/frontend.py +86 -81
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/HackaProfile.egg-info/SOURCES.txt +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/HackaProfile.egg-info/dependency_links.txt +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/HackaProfile.egg-info/entry_points.txt +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/HackaProfile.egg-info/requires.txt +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/HackaProfile.egg-info/top_level.txt +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/README.md +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/setup.cfg +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/__init__.py +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/backend.py +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/configTemplate/agent.pid +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/configTemplate/hackaprofile.conf +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/configTemplate/hackatime.hackaprofile.conf +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/configTemplate/slack.hackaprofile.conf +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/hackatimeOA.py +0 -0
- {hackaprofile-1.1.0 → hackaprofile-1.2.0}/src/logTemplate/agent.log +0 -0
- {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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
rprint(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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(
|
|
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]
|
|
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
|
|
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
|
-
|
|
261
|
-
"Do you want to copy path to clipboard?",
|
|
262
|
-
default=False
|
|
263
|
-
|
|
264
|
-
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|