Skip to content

Commit d5e86a1

Browse files
author
Stefano Tranquillini
committed
Merge branch 'release/1.2.0'
2 parents 17b7fa6 + e4db778 commit d5e86a1

File tree

4 files changed

+52
-8
lines changed

4 files changed

+52
-8
lines changed

src/changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# [1.1.0] - ?
2+
- STEFANO: improving messages when connection is missing.
3+
14
# [1.0.0] - 2024-03-21
25
- STEFANO: a lot of things happened and changed. Since approved by google, it's time to make a major.
36

src/mvdist.fish

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
rm -r /Applications/Vince.app
2+
rm -r -f /Applications/Vince.app
33
cp -r dist/Vince.app /Applications/

src/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'argv_emulation': False,
1515
'plist': {'LSUIElement': True,
1616
'CFBundleName': 'Vince',
17-
'CFBundleShortVersionString': '0.0.1',
17+
'CFBundleShortVersionString': '1.2.0',
1818
},
1919
'iconfile':'icon.png',
2020
}

src/vince.py

+47-6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
from appdirs import user_data_dir
2020
from bs4 import BeautifulSoup
2121
import logging
22+
import urllib.request
23+
import time
24+
2225
logging.basicConfig(level=logging.INFO,
2326
format='%(asctime)s - %(levelname)s - %(message)s')
2427

@@ -39,6 +42,30 @@ def __init__(self):
3942
self.app_name = "Vince"
4043
self.settings = self.load_settings()
4144
self.current_events = []
45+
self.creds = None
46+
47+
48+
def _has_internet(self):
49+
50+
try:
51+
urllib.request.urlopen("https://www.google.com")
52+
return True
53+
except urllib.error.URLError:
54+
return False
55+
@rumps.timer(5)
56+
def _load(self,_):
57+
if self.creds:
58+
return
59+
if not self._has_internet():
60+
print(f"Waiting for internet ... ")
61+
self.title = "Waiting for internet ... "
62+
quit_btn = rumps.MenuItem("Quit")
63+
quit_btn.set_callback(self.quit)
64+
self.menu.clear()
65+
self.menu.add(quit_btn)
66+
return
67+
68+
4269

4370
data_dir = user_data_dir(self.app_name)
4471
file_path = os.path.join(data_dir, "token.json")
@@ -69,6 +96,8 @@ def __init__(self):
6996

7097
@rumps.timer(90*5)
7198
def timely_load_events(self, _):
99+
if not self.creds:
100+
return
72101
self.load_events()
73102

74103
def load_events(self):
@@ -199,21 +228,29 @@ def build_menu(self):
199228
self.menu.add(quit_btn)
200229

201230
def open_browser(self, sender):
231+
print(self.settings.get('app_meet',""))
202232
if self.settings['link_opening_enabled']:
203233
for url in sender.urls:
234+
if app_meet:= self.settings.get('app_meet',""):
235+
if url.startswith("https://meet.google.com"):
236+
cmd = fr"open -a {app_meet} "
237+
print(cmd)
238+
os.system(cmd)
239+
return
240+
204241
webbrowser.open(url)
205242

206243
@rumps.clicked("Refresh Menu")
207244
def refresh_menu(self, _):
208245
self.load_events()
209246
self.build_menu()
210247
self.update_exiting_events(None)
211-
212-
213248

214249

215250
@rumps.timer(61)
216251
def update_exiting_events(self, _):
252+
if not self.creds:
253+
return
217254
# every 60 seconds remove the events that are past.
218255
current_datetime = datetime.now(pytz.utc)
219256
res = []
@@ -276,6 +313,8 @@ def _get_next_events(self):
276313

277314
@rumps.timer(1)
278315
def update_bar_str(self, _):
316+
if not self.creds:
317+
return
279318
if self.settings['show_menu_bar']:
280319
# updates the bar
281320
if self.menu_items:
@@ -347,13 +386,15 @@ def _str_event_menu_next(self, element):
347386
if element:
348387
hours, minutes = self._time_left(
349388
element['start'], current_datetime)
350-
title += f" [{element['summary'][:20]} in {hours:02d}:{minutes:02d}]"
389+
title = f" [{element['summary'][:20]} in {hours:02d}:{minutes:02d}]"
351390
return title
352391
else:
353392
return ""
354393

355394
@rumps.timer(1)
356395
def send_notification_(self, _):
396+
if not self.creds:
397+
return
357398
if self.settings['notifications']:
358399

359400
if self.menu_items:
@@ -385,6 +426,8 @@ def send_notification_(self, _):
385426

386427
@rumps.timer(1)
387428
def send_and_open_link(self, _):
429+
if not self.creds:
430+
return
388431
if self.settings['link_opening_enabled']:
389432
# 1 min beofre the meeting it opens the browser with the link
390433
# you can't miss it.
@@ -409,9 +452,6 @@ def send_and_open_link(self, _):
409452
@rumps.clicked("Quit")
410453
def quit(self, _):
411454
print('over')
412-
data_dir = user_data_dir(self.app_name)
413-
file_path = os.path.join(data_dir, "token.json")
414-
os.remove(file_path)
415455
rumps.quit_application()
416456

417457
def _convert_minutes_to_epoch(self, mins):
@@ -481,6 +521,7 @@ def load_settings(self):
481521
"calendars": ["primary"],
482522
"link_opening_enabled": True,
483523
"show_menu_bar": True,
524+
"app_meet":"",
484525
"notifications": [
485526
{
486527
"time_left": 5,

0 commit comments

Comments
 (0)