Skip to content

Commit

Permalink
version 1.1.2
Browse files Browse the repository at this point in the history
Fixed the program crashing when the token was invalid
  • Loading branch information
MrStickyPiston committed Nov 12, 2024
1 parent 8fcfe03 commit 9e528ec
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions build/stickyhours/android/gradle/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {

defaultConfig {
applicationId "io.github.mrstickypiston.stickyhours"
versionCode 010101
versionName "1.1.1"
versionCode 010102
versionName "1.1.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

// Briefcase currently requires API Level 24 for the `pidof` command, and the `--pid`
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[tool.briefcase]
project_name = "StickyHours"
bundle = "io.github.mrstickypiston"
version = "1.1.1"
version = "1.1.2"
url = "https://mrstickypiston.is-a.dev/projects/sticky-hours"
license.file = "LICENSE"
author = "MrStickyPiston"
Expand Down
9 changes: 9 additions & 0 deletions src/io.github.mrstickypiston.stickyhours.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@

# Releases
<releases>
<release version="1.1.2" date="2024-11-12">
<url type="details">https://github.com/MrStickyPiston/StickyHours/releases/tag/1.1.2</url>
<description>
<p> Sticky Hours 1.1.2</p>
<ul>
<li>Fixed the program crashing when the token was invalid</li>
</ul>
</description>
</release>
<release version="1.1.1" date="2024-10-21">
<url type="details">https://github.com/MrStickyPiston/StickyHours/releases/tag/1.1.1</url>
<description>
Expand Down
1 change: 1 addition & 0 deletions src/stickyhours/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def startup(self):

self.config = configparser.ConfigParser(allow_no_value=True)
self.config.read(self.config_dir / 'stickyhours.ini')
logging.info(f"Read config from: {self.config_dir}")

if 'user' not in self.config.sections():
self.config['user'] = {}
Expand Down
5 changes: 4 additions & 1 deletion src/stickyhours/zapi/zermelo.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,15 @@ def check_token(self, token, instance_id, min_seconds_left=60 * 60):
self.logger.error(f"Instance {instance_id} does not exist.")
raise ZermeloValueError(f"Incorrect instance id: {instance_id}")

if r.status_code == 401:
raise ZermeloAuthException(f"Invalid token: {token} for instance {instance_id}")

raise ZermeloApiHttpStatusException(r.status_code, r.text)

if expires_seconds - now_seconds > min_seconds_left:
self.logger.info(f"Token expires in {timedelta(seconds=expires_seconds - now_seconds)}")
return True
self.logger.info(f"Expired token: {token}")
self.logger.info(f"Nearly expired token: {token}")
return False

except (AttributeError, IndexError, json.decoder.JSONDecodeError) as e:
Expand Down

0 comments on commit 9e528ec

Please sign in to comment.