Beispiel #1
0
    def setup(self, force=False):
        n7      = __addon__.getSetting("N7")
        warning = __addon__.getSetting("warning")

        if warning != 'done':
            dialog = xbmcgui.Dialog()
            info = dialog.yesno("N7 TV APP", _(30100), _(30101), _(30102), _(30103), _(30104))
            if info:
                __addon__.setSetting("warning", "done")
            else:
                return False

        if n7 and not force:
            self.getControl( 205 ).setLabel( n7 )
            if api.request(n7, api.DISCOVER, True):
                self.tuner = n7
                log("N7 tuner ip loaded from cache: %s" % n7)
                return True
            else:
                dialog = xbmcgui.Dialog()
                dialog.ok(_(30114), _(30105) % (n7, ))

        #Automatic scan
        dialog = xbmcgui.Dialog()
        if dialog.yesno(_(30107), _(30108),_(30109), "", _(30110), _(30111)):
            scanner = api.scan()
            if scanner.run():
                dialog = xbmcgui.Dialog()
                if len(scanner.n7) > 1:
                    pos = dialog.select(_(30106), scanner.n7)
                    n7  = scanner.n7[pos]         
                else:
                    n7 = scanner.n7[0]
                    txt = _(30112) % n7
                    xbmc.executebuiltin("Notification(%s,%s,2)" % (__scriptname__ , txt))
                __addon__.setSetting("N7", n7)
                self.tuner = n7
                log("N7 tuner selected: %s" % n7)
                self.getControl( 205 ).setLabel( n7 )
                del scanner
                return True
            else:
                xbmc.executebuiltin("Notification(%s,%s,2)" % (__scriptname__ ,_(30117)))

        #Manual IP
        n7 = dialog.numeric(3, _(30111))
        if api.request(n7, api.DISCOVER, True):
            __addon__.setSetting("N7", n7)
            txt = _(30112) % n7
            self.tuner = n7
            self.getControl( 205 ).setLabel( n7 )
            log("N7 tuner manually entered: %s" % n7)
            return True
        else:
            dialog.ok(_(30114), _(30105) % n7, _(30115))
            __addon__.setSetting("N7", "")
            xbmc.sleep(3000)
            self.close()
Beispiel #2
0
def scan(lang=None, qasida_number=None, line_number=None):

    response = api.scan(lang, qasida_number, line_number)
    items = sorted(response['Items'], key=lambda i: (int(i['vote_average'])), reverse=True)
    items = [{key:str(val) for key, val in item.items()} for item in items]
    items = items[0] if len(items) > 0 else items

    response = dict(next='show_translation',data=items)
    return flask.jsonify(response)
Beispiel #3
0
    def start_scan(self):
        class _args:
            outfile = TESTS_RESULTS_FILE_PATH
            cameras = [self.ui.cameraIndexSpin.value()
                       ]  #TODO: UN-WIRE THIS !!!!
            folder = IMAGES_FOLDER
            time = None
            autowrite = True
            poll = None
            debug = False

        self.scanning = True

        ok = api.scan(_args())  # TODO: Fill dictionary properly
        if ok:
            self.scanSuccess.emit()
        else:
            self.scanError.emit()

        self.scanning = False
Beispiel #4
0
    def start_scan(self):

        class _args:
            outfile = TESTS_RESULTS_FILE_PATH
            cameras = [self.ui.cameraIndexSpin.value()] #TODO: UN-WIRE THIS !!!!
            folder = IMAGES_FOLDER
            time = None
            autowrite = True
            poll = None
            debug = False

        self.scanning = True

        ok = api.scan(_args()) # TODO: Fill dictionary properly
        if ok:
            self.scanSuccess.emit()
        else:
            self.scanError.emit()

        self.scanning = False
Beispiel #5
0
def login_dashboard():
    on = api.get_state_on()
    current_low = api.get_state_current_low()
    current_high = api.get_state_current_high()
    #currently manually set to collect the power consumption of April (CHANGE REQUIRED FOR EACH MONTH)
    kwh = api.get_state_power_consumption()
    #cost estimiated based on 2019 Summary of Eastern Massachusetts Electric Rates: less than 10 cents distribution = $0.06396, ,,transmition = 0.02  for each kwh
    # * decimal.Decimal(0.10) * decimal.Decimal(120) * decimal.Decimal(1/3600000)
    #this kwh is actually seconds.
    estimated_cost = round(decimal.Decimal(kwh) * decimal.Decimal(0.0000033333) ,5)
    items = api.scan()
    time = []
    outside_temp = []
    inside_temp = []
    humidity = []
    light_level = []
    #soil moisture
    s1 = []
    s2 = []
    s3 = []

    #print(type(items))
    #print(type(items[0]['Humidmity']))

    for i in range(len(items)):
        time.append(int(items[i]['Time']))
        outside_temp.append(int(items[i]['Temperature_outside']))
        inside_temp.append(int(items[i]['Temperature_inside']))
        humidity.append(int(items[i]['Humidmity']))
        s1.append(int(items[i]['Soil_Moisture_1']))
        s2.append(int(items[i]['Soil_Moisture_2']))
        s3.append(int(items[i]['Soil_Moisture_3']))
        light_level.append(int(items[i]['Light_level']))

    #Get kwh for each monthly_energy month for 12 months: [100,221,22311,...]
    monthly_energy = api.get_energy_used()
    print("Here is the monthly energy type")
    print(type(monthly_energy[0]))

    monthly_cost = []
    for i in range(len(monthly_energy)):
        #monthly_cost.append(int(round(decimal.Decimal(monthly_energy[i]) * decimal.Decimal(0.10),2)))
        monthly_cost.append(int(round(decimal.Decimal(monthly_energy[i]) * decimal.Decimal(0.33333),5)))

    #get current notification time
    current_notification_time_string_list = api.get_notification_time()
    current_notification_hour = current_notification_time_string_list[0]
    current_notification_minute = current_notification_time_string_list[1]
    current_notification_time = current_notification_time_string_list[2]







    ron_label = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,2400000000000000000000000]
    print(type(ron_label[0]))
    print(outside_temp)
    return render_template('dashboard_result.html',temperature_threshold = 60, heater_state = 'On',
     ron_label= ron_label,
     time = time, outside_temp = outside_temp, inside_temp = inside_temp, humidity = humidity , s1 = s1, s2 = s2, s3 = s3, light_level = light_level
     , on = on , current_low = current_low, current_high = current_high, estimated_cost = estimated_cost
     ,monthly_energy = monthly_energy, monthly_cost = monthly_cost
     ,current_notification_hour = current_notification_hour, current_notification_minute = current_notification_minute, current_notification_time = current_notification_time)
Beispiel #6
0
def db_demo():
    item = api.scan()
    content = get_file('static/login.html')
    return Response(content, mimetype="text/html")
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2020/4/4 6:14 PM
# @Author  : w8ay
# @File    : test_command_php_code.py
from api import scan, output

url = "http://scanbox.io/code_exec/code.php?code=a&submit=submit"
module_name = "command_php_code"
scan(url, module_name)
for item in output.collect:
    print(item)