예제 #1
0
    def log_user(self):

        if self.edit_username.text() == "":
            alert(WARNING, WARNING, NULL_USERNAME, parent=self)
            self.edit_username.setFocus()
            return
        if self.edit_password.text() == "":
            alert(WARNING, WARNING, NULL_PASSWORD, parent=self)
            self.edit_password.setFocus()
            return

        ret = self.client.login(self.edit_username.text(),
                                self.edit_password.text())

        if ret == ReturnCodes.SUCCESS:
            dash = dashboard.Dashboard(width=self.parent.width,
                                       height=self.parent.height,
                                       papa=self.parent,
                                       client=self.client)
            self.close()
            self.parent.hide()
            dash.exec_()

        if ret == ReturnCodes.UNKNOWN_ERROR:
            alert(WARNING, WARNING, MI_SCUZI, parent=self)
            return
        if ret == ReturnCodes.INVALID_USER:
            alert(ERROR, ERROR, INVALID_USER, parent=self)
            self.edit_username.setFocus()
            return
        if ret == ReturnCodes.INVALID_PASSWORD:
            alert(ERROR, ERROR, INVALID_PASSWORD, parent=self)
            self.edit_password.setFocus()
            self.edit_password.clear()
예제 #2
0
    def __init__(self):
        database.initDb()
        adminpanel = admin.Admin()
        verified = adminpanel.start()
        if verified:

            self.dashboard = dashboard.Dashboard()
        print("I DO NOT LIKE UNVERIFIED PEOPLE")
예제 #3
0
 def login(self):
     if database.validateUser(self.txt_username.get(),
                              self.txt_password.get()):
         print("Logged in as : ", self.txt_username.get(),
               self.txt_password.get())
         dash = dashboard.Dashboard()
         dash.mainloop()
     else:
         print("Not a user.")
         msg.showerror(messages.login_error[0], messages.login_error[1])
예제 #4
0
    def __init__(self, client, name, drive_func):
        self.client = client
        self.drive_func = drive_func
        self.name = name
        self.track = track.Track()
        self.dashboard = dashboard.Dashboard()
        self.finish_line = finish.FinishLine()
        self.players = {}
        self.cars = [
            car.Car(1, 0, 4),
            car.Car(2, 1, 4),
            car.Car(3, 2, 4),
            car.Car(4, 3, 4)
        ]
        self.world = world.generate_world(self)
        pygame.init()
        self.surface = pygame.display.set_mode(config.window_size)
        self.looper = task.LoopingCall(self.tick)

        self.init()
        frame_delay = 1.0 / config.frame_rate
        self.looper.start(frame_delay)
예제 #5
0
    def robotInit(self):
        frontLeft = wpilib.Victor(0)
        frontRight = wpilib.Victor(1)
        rearLeft = wpilib.Victor(2)
        rearRight = wpilib.Victor(3)
        self.robot_drive = wpilib.RobotDrive(frontLeftMotor=frontLeft,
                                             frontRightMotor=frontRight,
                                             rearLeftMotor=rearLeft,
                                             rearRightMotor=rearRight)
        self.joystick = wpilib.Joystick(0)

        self.gyro = wpilib.Gyro(0)
        #calibrate the gyro
        self.gyro_drift = 0.0
        wpilib.Timer.delay(2.0)
        last_angle = self.gyro.getAngle()
        wpilib.Timer.delay(10.0)
        self.gyro_drift = (self.gyro.getAngle() - last_angle) / 10.0

        self.timer = wpilib.Timer()

        self.dashboard = dashboard.Dashboard()

        def send_thread():
            while True:
                self.dashboard.send_udp(dashboard.encode_gyro(
                    self.get_angle()))
                wpilib.Timer.delay(0.05)

        def recv_thread():
            while True:
                self.dashboard.get_msg()

        t_send = threading.Thread(target=send_thread)
        t_send.daemon = True
        t_send.start()
        t_recv = threading.Thread(target=recv_thread)
        t_recv.daemon = True
예제 #6
0
def app():
    users = dashboard.MockDataSource(
        schema=typesystem.Schema(
            fields={
                "pk":
                typesystem.Integer(title="Identity",
                                   read_only=True,
                                   default=dashboard.autoincrement()),
                "username":
                typesystem.String(title="Username", max_length=100),
                "is_admin":
                typesystem.Boolean(title="Is Admin", default=False),
                "joined":
                typesystem.DateTime(title="Joined",
                                    read_only=True,
                                    default=datetime.datetime.now),
            }),
        initial=[{
            "username": f"user{i}@example.org",
            "is_admin": False,
        } for i in range(123)],
    )

    user_table = dashboard.DashboardTable(ident="users",
                                          title="Users",
                                          datasource=users)
    admin = dashboard.Dashboard(tables=[user_table])

    return Starlette(routes=[
        Mount(
            "/admin",
            admin,
            name="dashboard",
        ),
        Mount("/statics", ..., name="static"),
    ])
예제 #7
0
def main():
    global sig_command, refreshing, is_status_changed, lcd
    global initial_time
    global temp, temp_avg_accu, temp_avg_counter, temp_avg_sum
    global log_temp_avg_accu, log_temp_avg_counter, log_temp_avg_sum

    last_update_min = -1

    # will sys.exit(-1) if other instance is running
    singleton.SingleInstance()

    # first initializations
    init()

    # main loop
    log_data('start')
    show_message('HOMPI', 'HOMPI START')

    while True:
        try:
            # save cycle start time
            cycle_start_time = datetime.datetime.now()
            secs_elapsed = round(
                (cycle_start_time - initial_time).total_seconds())
            # time in the day
            current_time = datetime.datetime.today().hour * 100 + \
                datetime.datetime.today().minute

            #  refresh at end time (do once per minute)
            if (io_status.req_end_time == current_time and
                    last_update_min != datetime.datetime.today().minute):
                last_update_min = datetime.datetime.today().minute
                refreshing = True

            # OPERATIONS NOT DONE ON REFRESH - START
            # update hompiS
            if secs_elapsed >= task_at_secs['hompi_slaves_refresh']:
                sensor.hompi_slaves_refresh(io_status.hompi_slaves)

            # update I/O: meteo
            if secs_elapsed >= task_at_secs['get_meteo'] \
                    and config.MODULE_METEO:
                meteo()

            # aphorism
            if secs_elapsed >= task_at_secs['get_aphorism'] \
                    and config.MODULE_APHORISM:
                aphorism()

            # re-sync things
            if secs_elapsed >= task_at_secs['refresh']:
                # restart LCD
                lcd = dashboard.Dashboard()
                # ambient color
                if config.MODULE_AMBIENT:
                    io_status.current_ambient_color = ambient.ambient_refresh()
                # temp sensor failure: reset temp sampling
                if config.MODULE_TEMP and temp_avg_sum == 0:
                    temp_avg_accu = temp_avg_counter = 0.0
                    io_status.int_temp_c = 0.0
            # OPERATIONS NOT DONE ON REFRESH - END

            # update I/O (ack occurring here gets ambient control)
            if secs_elapsed >= task_at_secs['update_io'] or refreshing:
                process_input()

            # get temperature
            if (secs_elapsed >= task_at_secs[
                    'get_temp'] or refreshing) and config.MODULE_TEMP:
                get_temperature()

            # update temperature
            if (secs_elapsed >= task_at_secs[
                    'update_temp'] or refreshing):
                # save new temperature (if valid)
                if temp_avg_sum != 0:
                    io_status.int_temp_c = \
                        round(temp_avg_accu / temp_avg_sum, 2)
                # reset temp sampling
                temp_avg_accu = temp_avg_counter = temp_avg_sum = 0

            # refresh program
            if secs_elapsed >= task_at_secs['refresh'] or refreshing:
                refresh_program(current_time)

            # compute status (heating, switches, ...)
            is_status_changed |= compute_status()

            # update I/O: output
            if secs_elapsed >= task_at_secs['update_io'] or \
                    refreshing or is_status_changed:
                update_output()

            # log data (check task_at_mins)
            if (datetime.datetime.now().minute == task_at_mins[
                'log'] or refreshing) \
                    and log_temp_avg_sum > 0:
                io_status.int_temp_c = round(
                    log_temp_avg_accu / log_temp_avg_sum, 2)
                log_temp_avg_accu = log_temp_avg_counter = log_temp_avg_sum = 0
                log_data('refreshing' if refreshing else '.')

            # update LCD message (NOT ON REFRESH)
            if secs_elapsed >= task_at_secs['update_lcd_content']:
                update_lcd_content()

            # status speech
            if is_status_changed and config.MODULE_SPEECH:
                command = config.SPEECH_COMMAND.format(
                    io_status.get_status_text()) + ' &'
                print('status changed: executing {}'.format(command))
                os.system(command)

        except (KeyboardInterrupt, SystemExit):
            # cleanup sensors & LCD
            sensor.cleanup()
            lcd.cleanup()
            ambient.cleanup()
            raise
        except Exception:
            log_stderr(traceback.format_exc())
            log_data('EXC: {}'.format(traceback.format_exc()))
        finally:
            # stop refreshing cycle, reset status change
            refreshing = is_status_changed = False

            # update scheduled tasks (skip any lost task)
            for task in task_every_secs.keys():
                while secs_elapsed >= task_at_secs[task]:
                    task_at_secs[task] += task_every_secs[task]

            for task in task_every_mins.keys():
                if datetime.datetime.now().minute == task_at_mins[task]:
                    task_at_mins[task] += task_every_mins[task]
                    while task_at_mins[task] >= 60:
                        task_at_mins[task] -= 60

            # sync ambient color
            io_status.current_ambient_color = ambient.update()

            try:
                # update lcd screen to 1 sec approx.
                cycle_duration = (datetime.datetime.now() - cycle_start_time)\
                    .total_seconds()
                while cycle_duration < 1:
                    # catch command "interrupt" (jump to new cycle)
                    if sig_command:
                        break
                    frame_duration = lcd.update(io_status)
                    if frame_duration < .25:
                        time.sleep(.25 - frame_duration)
                    cycle_duration += .25

                if sig_command:
                    sig_command = False
                    refreshing = True

            except (KeyboardInterrupt, SystemExit):
                # cleanup sensors & LCD
                sensor.cleanup()
                lcd.cleanup()
                ambient.cleanup()
                raise
            except Exception:
                # LCD I/O error: refresh LCD screen
                log_stderr(traceback.format_exc())
                log_stderr('LCD I/O error: trying to recover..')
                time.sleep(1)
                lcd = dashboard.Dashboard()
예제 #8
0
import db
import io_data
import sensors
import dashboard
import resources
import ambient
import random

import socket

from tendo import singleton
from utils import log_stderr, os_async_command

io_status = io_data.Status()
sensor = sensors.Sensors()
lcd = dashboard.Dashboard()
ambient = ambient.Ambient()

TEST_INIT_TEMP = 20.0
TEST_DELTA_EXT_INT_COEFF = .001
TEST_DELTA_THERMO_ON_TEMP_C = .03
current_status = ''
sig_command = False
is_status_changed = True

initial_time = datetime.datetime.now()
sig_switch_timeout = [datetime.datetime.now()]*len(config.BUTTONS)

temp = temp_avg_accu = temp_avg_sum = 0.0
temp_avg_counter = 0
log_temp_avg_accu = log_temp_avg_sum = 0.0
예제 #9
0
    print(
        "#                                                                                   #"
    )
    print(
        "#                                       AI                                          #"
    )
    print(
        "#                                                                                   #"
    )
    print(
        "#                                                                                   #"
    )
    print(
        "#                                                                                   #"
    )
    print(
        "#####################################################################################"
    )
    print("Use an action:")

    print("1 ) List Persons")
    print("2 ) Insert a Persons")
    print("3 ) Drop Table Persons")
    print("4 ) Create Table Persons")
    print("5 ) List Tables")

    action = input()

    Dashboard = D.Dashboard()
    Dashboard.start(action)
    def __init__(self, ad, loop, logger, access, **config):

        self.AD = ad
        self.logger = logger
        self.acc = access

        self.dashboard_dir = None
        self._process_arg("dashboard_dir", config)

        self.dash_password = None
        self._process_arg("dash_password", config)

        self.dash_url = None
        self._process_arg("dash_url", config)

        self.config_dir = None
        self._process_arg("config_dir", config)

        self.dash_compile_on_start = False
        self._process_arg("dash_compile_on_start", config)

        self.dash_force_compile = False
        self._process_arg("dash_force_compile", config)

        self.work_factor = 8
        self._process_arg("work_factor", config)

        self.profile_dashboard = False
        self._process_arg("profile_dashboard", config)

        self.dash_ssl_certificate = None
        self._process_arg("dash_ssl_certificate", config)

        self.dash_ssl_key = None
        self._process_arg("dash_ssl_key", config)

        self.rss_feeds = None
        self._process_arg("rss_feeds", config)

        self.rss_update = None
        self._process_arg("rss_update", config)

        self.rss_last_update = None

        self.stopping = False

        url = urlparse(self.dash_url)

        dash_net = url.netloc.split(":")
        self.dash_host = dash_net[0]
        try:
            self.dash_port = dash_net[1]
        except IndexError:
            self.dash_port = 80

        if self.dash_host == "":
            raise ValueError("Invalid host for 'dash_url'")

        # find dashboard dir

        if self.dashboard_dir is None:
            if self.config_dir is None:
                self.dashboard_dir = utils.find_path("dashboards")
            else:
                self.dashboard_dir = os.path.join(self.config_dir, "dashboards")


            #
            # Setup compile directories
            #
            if self.config_dir is None:
                self.compile_dir = utils.find_path("compiled")
            else:
                self.compile_dir = os.path.join(self.config_dir, "compiled")


        # Setup WS handler

        self.app = web.Application()
        self.app['websockets'] = {}

        self.loop = loop
        self.executor = concurrent.futures.ThreadPoolExecutor(max_workers=5)

        try:
            self.dashboard_obj = dashboard.Dashboard(self.config_dir, access,
                                                 dash_compile_on_start=self.dash_compile_on_start,
                                                 dash_force_compile=self.dash_force_compile,
                                                 profile_dashboard=self.profile_dashboard,
                                                 dashboard_dir = self.dashboard_dir,
                                                     )
            self.setup_routes()

            if self.dash_ssl_certificate is not None and self.dash_ssl_key is not None:
                context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
                context.load_cert_chain(self.dash_ssl_certificate, self.dash_ssl_key)
            else:
                context = None

            handler = self.app.make_handler()

            f = loop.create_server(handler, "0.0.0.0", int(self.dash_port), ssl=context)

            loop.create_task(f)
            loop.create_task(self.update_rss())
        except:
            self.log("WARNING", '-' * 60)
            self.log("WARNING", "Unexpected error in dashboard thread")
            self.log("WARNING", '-' * 60)
            self.log("WARNING", traceback.format_exc())
            self.log("WARNING", '-' * 60)
예제 #11
0
파일: example.py 프로젝트: encode/dashboard
    fields = {
        'id':
        orm.Integer(title="ID", primary_key=True, read_only=True),
        'created':
        orm.DateTime(title="Created",
                     default=datetime.datetime.now,
                     read_only=True),
        'text':
        orm.String(title="Text", max_length=100),
        'completed':
        orm.Boolean(title="Completed", default=False)
    }


admin = dashboard.Dashboard(tables=[
    dashboard.DashboardTable(ident="notes",
                             title="Notes",
                             datasource=Notes.objects.order_by('-id')),
])

routes = [
    Mount("/admin", app=admin, name='dashboard'),
    Mount("/statics", app=statics, name='static'),
    Route("/", endpoint=RedirectResponse(url='/admin')),
]

app = Starlette(debug=True,
                routes=routes,
                on_startup=[database.connect],
                on_shutdown=[database.disconnect])
예제 #12
0
from chatbot import MoC_Chatbot
from flask import Flask, flash, render_template, request, jsonify, send_file, session, make_response, url_for, redirect
from flask_cors import CORS, cross_origin
import dashboard
import json
import jwt
from functools import wraps
from datetime import timedelta, datetime
import jwt
from config import systemConfig
import os

dashboard_obj = dashboard.Dashboard()

app = Flask(__name__)
CORS(app, supports_credentials=True)
app.static_folder = 'static'
app.secret_key = systemConfig.flask_secret_key
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(minutes=1440)
moc_chatbot = MoC_Chatbot()


@app.after_request
def after_request(response):
    response.headers.set("Access-Control-Allow-Credentials", "true")
    return response


def token_check(func):
    @wraps(func)
    def decorated(*args, **kwargs):
예제 #13
0
 def startDashboard(self):
     dialog = QtWidgets.QDialog()
     dialog.ui = dashboard.Dashboard()
     dialog.ui.setupUi(dialog)
     dialog.exec_()
예제 #14
0
def get_all_dashboard_validation_selections():
    db = dashboard.Dashboard()
    return db.get_all_current_data_validation_selections()