Compare commits
10 Commits
67313e7aa7
...
b5a62547a0
| Author | SHA1 | Date | |
|---|---|---|---|
| b5a62547a0 | |||
| fb8f5ac70a | |||
| 64475f3668 | |||
| 968db61b63 | |||
| ddb284300d | |||
| d768bcb20d | |||
| f77db360ab | |||
| 44cca37df8 | |||
| f8f365277c | |||
| d953196137 |
+5
-1
@@ -1 +1,5 @@
|
|||||||
.auth*
|
.auth*
|
||||||
|
config.json
|
||||||
|
./venv/
|
||||||
|
/.idea/inspectionProfiles/
|
||||||
|
/.idea/
|
||||||
|
|||||||
+121
@@ -0,0 +1,121 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for software.
|
||||||
|
By contrast, the GPL guarantees your freedom to share and change all versions.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you these rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, (2) offer you this License.
|
||||||
|
|
||||||
|
For protection, the GPL explains there is no warranty for free software.
|
||||||
|
|
||||||
|
Some devices deny users access to install or run modified versions. This is incompatible
|
||||||
|
with protecting users' freedom to change software.
|
||||||
|
|
||||||
|
Finally, every program is threatened by software patents. The GPL assures that patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of works.
|
||||||
|
"The Program" refers to any copyrightable work licensed under this License.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
The "source code" for a work means the preferred form for making modifications.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
All rights granted under this License are granted for the term of copyright on the Program,
|
||||||
|
and are irrevocable provided the stated conditions are met.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
No covered work shall be deemed part of an effective technological measure.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
You may convey verbatim copies of the Program's source code as you receive it.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
You may convey a work based on the Program under section 4, provided that you also meet all conditions:
|
||||||
|
a) The work must carry prominent notices stating that you modified it.
|
||||||
|
b) You must license the entire work under this License.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
You may convey a covered work in object code form under sections 4 and 5, provided that you also convey
|
||||||
|
the machine-readable Corresponding Source under the terms of this License.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
"Additional permissions" are terms that supplement the terms of this License by making exceptions.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
You may not propagate or modify a covered work except as expressly provided under this License.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
You are not required to accept this License in order to receive or run a copy of the Program.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
Each time you convey a covered work, the recipient automatically receives a license from the original licensors.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this License of the Program.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
If conditions are imposed on you that contradict the conditions of this License, they do not excuse you from the conditions.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
You have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER BE LIABLE TO YOU FOR DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest possible use to the public,
|
||||||
|
the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program:
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> Lucas Oskorep
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
|
||||||
|
Copyright (C) YOUR NAME 2024
|
||||||
|
|
||||||
|
Licensed under the GNU General Public License Version 3 (GPL-3.0-or-later).
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GPL v3 as published by the Free Software Foundation,
|
||||||
|
either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
See <https://www.gnu.org/licenses/> for full license text.
|
||||||
+8
-6
@@ -37,8 +37,9 @@ class CalGrab(object):
|
|||||||
now = datetime.utcnow()
|
now = datetime.utcnow()
|
||||||
if start == None:
|
if start == None:
|
||||||
start = now
|
start = now
|
||||||
events = []
|
all_events = []
|
||||||
for calendar in self.calendars:
|
for calendar in self.calendars:
|
||||||
|
print(f"processing {calendar}")
|
||||||
events_result = self.service.events().list(
|
events_result = self.service.events().list(
|
||||||
calendarId=calendar,
|
calendarId=calendar,
|
||||||
timeMin=now.isoformat() + 'Z',
|
timeMin=now.isoformat() + 'Z',
|
||||||
@@ -50,13 +51,14 @@ class CalGrab(object):
|
|||||||
if not events:
|
if not events:
|
||||||
print('No upcoming events found.')
|
print('No upcoming events found.')
|
||||||
return
|
return
|
||||||
events.extend([i for i in [Event.get_from_gcal_api_json(json) for json in events] if i is not None])
|
all_events.extend([i for i in [Event.get_from_gcal_api_json(json) for json in events] if i is not None])
|
||||||
print(events)
|
print(all_events)
|
||||||
events = sorted(events, key=lambda event: event.start_time)
|
all_events = sorted(all_events, key=lambda event: event.start_time)
|
||||||
for callback in self.callbacks:
|
for callback in self.callbacks:
|
||||||
callback(events)
|
callback(all_events)
|
||||||
if time_to_update > 0 and (now - start).total_seconds() > time_to_update:
|
if time_to_update > 0 and (now - start).total_seconds() > time_to_update:
|
||||||
return
|
return
|
||||||
sleep(frequency)
|
sleep(frequency)
|
||||||
except HttpError as error:
|
except Exception as error:
|
||||||
print('An error occurred: %s' % error)
|
print('An error occurred: %s' % error)
|
||||||
|
sleep(60)
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
[
|
[
|
||||||
"(your email here)"
|
"loskorep@productiveedge.com"
|
||||||
]
|
]
|
||||||
+3
-2
@@ -10,7 +10,7 @@ from calendar_grabber import CalGrab
|
|||||||
TIMEZONE = timezone('US/Eastern')
|
TIMEZONE = timezone('US/Eastern')
|
||||||
WORK_START = time(9, 00)
|
WORK_START = time(9, 00)
|
||||||
WORK_STOP = time(17, 00)
|
WORK_STOP = time(17, 00)
|
||||||
WORK_DAYS = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
|
WORK_DAYS = [0, 1, 2, 3, 4]
|
||||||
with open("config.json") as f:
|
with open("config.json") as f:
|
||||||
CALENDARS = json.load(f)
|
CALENDARS = json.load(f)
|
||||||
print(CALENDARS)
|
print(CALENDARS)
|
||||||
@@ -55,6 +55,7 @@ def process_events(events):
|
|||||||
now = datetime.now(tz=TIMEZONE)
|
now = datetime.now(tz=TIMEZONE)
|
||||||
is_working_time = is_work_time(now.time())
|
is_working_time = is_work_time(now.time())
|
||||||
is_weekend = now.weekday() not in WORK_DAYS
|
is_weekend = now.weekday() not in WORK_DAYS
|
||||||
|
print(is_weekend, now.weekday())
|
||||||
|
|
||||||
if is_event_active(events, now):
|
if is_event_active(events, now):
|
||||||
if is_weekend:
|
if is_weekend:
|
||||||
@@ -71,7 +72,7 @@ def process_events(events):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
cg = CalGrab("./.auth.json", [CALENDARS], [process_events])
|
cg = CalGrab("./.auth.json", CALENDARS, [process_events])
|
||||||
cg.update_at_interval(10)
|
cg.update_at_interval(10)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user