Giter Site home page Giter Site logo

roguedbear / 12-hour-server Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 104 KB

a python script to put the home "server" to sleep when wifi is disconnected at night, and wake up early the next day

License: GNU General Public License v3.0

Python 100.00%
server self-hosted automation scripts python-automation python-script sleep-mode sleep-computer

12-hour-server's People

Contributors

github-actions[bot] avatar lint-action avatar roguedbear avatar

Watchers

 avatar

12-hour-server's Issues

delete wake timers when the program exits

if the user exits the program (ctrl+c) then delete the wake timers that might be there if the program was in sleep state.
If the wake timer was for a sufficiently large duration and the user puts the computer to sleep, the machine could wake up undesirably and deplete battery (if laptop).

as of now, i haven't been able to find a way to delete waketimers in linux, so if you face this specific issue just dont use sleep_interval key in config.yaml

add unit testing.

since making changes is getting extremely tedious with worrying about if anything that works is gonna break or not

possible library to look into: freezegun

program stuck on "sending alert message" loop until it finally sends the alert preventing it from moving on to different phase

Lines of code creating the problem:

12-hour-server/smart_sleep.py

Lines 1108 to 1119 in a2d2d5e

while True:
try:
alert_onTelegram(
"Hello There!\nToday the internet came back quite early.\nLast sleep time: `{}`".format(
LAST_SLEEP_TIME_byProgram.strftime("%b %d %H:%M:%S")
if LAST_SLEEP_TIME_byProgram != datetime.datetime.min
else LAST_SLEEP_TIME.strftime("%b %d %H:%M:%S")
)
)
break
except Exception:
continue

While this loop is running, the program would continue to spam alert_onTelegram function until it sends a message, preventing it from moving on to a different phase when enough time passes and potentially keeping the laptop awake the entire night

instead it should:

  • use a timeout/sleep instead of spamming that function
  • keep track of current phase, if we move on to midnight break the loop (and possibly store the current message to be sent in the next day's loop)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.