Changeset - 047cc1b40374
[Not reviewed]
default
1 2 0
Dennis Fink - 3 years ago 2022-07-19 19:18:33
dennis.fink@c3l.lu
Remove state endpoint
3 files changed with 2 insertions and 35 deletions:
0 comments (0 inline, 0 general)
spaceapi/__init__.py
Show inline comments
 
@@ -82,25 +82,21 @@ def create_app():
 

	
 
    @app.after_request
 
    def add_headers(response):
 
        response.headers.setdefault("Access-Control-Allow-Origin", "*")
 
        response.headers.setdefault("Cache-Control", "no-cache")
 

	
 
        return response
 

	
 
    from .views import root_views
 

	
 
    app.register_blueprint(root_views)
 

	
 
    from .state import state_views
 

	
 
    app.register_blueprint(state_views, url_prefix="/state")
 

	
 
    from .sensors import sensors_views
 

	
 
    app.register_blueprint(sensors_views, url_prefix="/sensors")
 

	
 
    from .utils import ActiveStatusv14
 

	
 
    ActiveStatusv14().reload()
 

	
 
    return app
spaceapi/state.py
Show inline comments
 
deleted file
spaceapi/utils.py
Show inline comments
 
import email
 
import email.policy
 
import json
 
import os.path
 
import random
 
import smtplib
 
import ssl
 
from functools import partial, wraps
 
from functools import partial
 
from time import time
 

	
 
import mastodon
 
import tweepy
 
from flask import current_app, request
 

	
 
default_json_file_v14 = os.path.abspath("default_v14.json")
 
last_state_file_v14 = os.path.abspath("laststate_v14.json")
 

	
 
if not os.path.exists(default_json_file_v14):
 
    raise RuntimeError("default_v14.json does not exists!")
 
elif not os.path.isfile(default_json_file_v14):
 
@@ -35,25 +35,24 @@ possible_open_messages = (
 
)
 

	
 
possible_closed_messages = (
 
    standard_close_message,
 
    "We're closed now! See you soon.",
 
    "Sorry, we are closed now!",
 
    "The ChaosStuff is now closed! Come back another time!",
 
    "Poweroff process finished! We're closed!",
 
    "Singularity reached! The space is closed!",
 
    "Dream of electric sheeps! We are closed!",
 
)
 

	
 
get_identification_key = partial(first, keys=frozenset(("name", "location")))
 

	
 
RADIATON_SUBKEYS = frozenset(("alpha", "beta", "gamma", "beta_gamma"))
 

	
 

	
 
class Singleton:
 
    def __new__(cls, *args, **kwargs):
 
        key = str(hash(cls))
 

	
 
        if not hasattr(cls, "_instance_dict"):
 
            cls._instance_dict = {}
 

	
 
        if key not in cls._instance_dict:
 
@@ -282,21 +281,13 @@ def fuzzy_list_find(lst, key, value):
 

	
 
    raise ValueError
 

	
 

	
 
def first(iterable, keys):
 
    for key in keys:
 
        if key in iterable:
 
            return key
 

	
 
    raise ValueError
 

	
 

	
 
def pass_active_status(f):
 
    @wraps(f)
 
    def wrapper(*args, **kwargs):
 
        status = ActiveStatusv14()
 
        rv = f(status, *args, **kwargs)
 
        status.save_last_state()
 
        return rv
 

	
 
    return wrapper
 
get_identification_key = partial(first, keys=frozenset(("name", "location")))
0 comments (0 inline, 0 general)