diff --git a/my_lib/__init__.py b/my_lib/__init__.py deleted file mode 100644 index 2d85dec..0000000 --- a/my_lib/__init__.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/python - - -# ### constants & globals ### -from constants import * - -# ### classes ### -from classes import * - -# ### config ### -from config import * - -# ### logger to file ### -from loggerpatch import * -from loggers import * - -# ### definitions for settings screen ### -from settingsjson import * - -# ### registration ### -from registration import * - -# ### SIP ### -from settingssip import * -from callstats import * - -# ### tools ### -from itools import * -from audiotools import * -from tones import * -from timezonejson import * - -# ### NETLINK socket ### -from netlink import * - -# ### SW watchdog ### -from sw_watchdog import * - -# ### watches classes ### -from watches import * - -# ### button in Settings ### -from settingsbutton import * - -# ### input popup dialog ### -from inputdlg import * - -# ### yes|no popup dialog ### -from yesnodlg import * - -# ### popup dialogs ### -from alertdlg import * -from appstatusdlg import * -from settingsdlg import * - diff --git a/my_lib/alertdlg.py b/my_lib/alertdlg.py deleted file mode 100644 index aea80d9..0000000 --- a/my_lib/alertdlg.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -import kivy -kivy.require('1.9.0') - - -from kivy.lang import Builder -from kivy.logger import Logger #, LoggerHistory -from kivy.uix.boxlayout import BoxLayout -from kivy.uix.button import Button -#from kivy.uix.image import Image -from kivy.uix.label import Label -from kivy.uix.popup import Popup -#from kivy.uix.textinput import TextInput -#from kivy.uix.widget import Widget - -from constants import * -from itools import * - - -# ############################################################### -# -# Popup Class - alert popup dialog -# -# ############################################################### - -KV = ''' -BoxLayout: - orientation: 'vertical' - lblInfo: lblInfo - btok: btok - spacing: 10 - - Label: - text: '' - id: lblInfo - - BoxLayout: - orientation: 'horizontal' - size_hint_y: None - height: 48 - spacing: 5 - - Button: - text: 'OK' - id: btok -''' - - -class MyAlertBox(Popup): - "Yes or no popup box" - def __init__(self, **kwargs): - super(MyAlertBox, self).__init__(**kwargs) - - header = kwargs.get('titl') or 'Status' - info = kwargs.get('txt') or '' - self.cb = kwargs.get('cb') or None - ad = kwargs.get('ad') or False - - Logger.debug('%s: titl=$%s msg=%s' % (whoami(), header, info)) - - self.p = Builder.load_string(KV) - self.p.lblInfo.text = info - self.p.btok.bind(on_press=self.buttonOk) - - self.title = header - self.auto_dismiss = ad - self.size_hint = (.69, .69) - self.content = self.p - - - def buttonOk(self, b): - Logger.debug('%s:' % whoami()) - self.dismiss() - if not self.cb is None: self.cb() - - -# ############################################################################## diff --git a/my_lib/appstatusdlg.py b/my_lib/appstatusdlg.py deleted file mode 100644 index bf815d7..0000000 --- a/my_lib/appstatusdlg.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -import kivy -kivy.require('1.9.0') - -from alertdlg import * - - -# ############################################################### -# -# Popup Class - show app status info -# -# ############################################################### - -def myappstatus(titl, uptime, cinfo): - info = 'System uptime: %s\n\nIncoming calls: %d\nOutgoing calls: %d\nNot answered calls: %d\nNot responded calls: %d'\ - % (str(uptime), int(cinfo['in']), int(cinfo['out']), int(cinfo['noansw']), int(cinfo['noresp'])) - - MyAlertBox(titl=titl, txt=info, cb=None, ad=True).open() - - -# ############################################################################## diff --git a/my_lib/audiotools.py b/my_lib/audiotools.py deleted file mode 100644 index e5c8a37..0000000 --- a/my_lib/audiotools.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -from kivy.logger import Logger -from kivy.clock import Clock - -import threading -import RPi.GPIO as GPIO -import usb.core - -from time import sleep - -from constants import * -from itools import * -from nodeclient import * - - -############################################################### -# -# Declarations -# -# ############################################################### - -VENDOR_ID = 0x0572 # Conexant -PRODUCT_ID = 0x1410 # USB audio - -RST_PIN = 2 #24 -RST_TIME = .2 - -device_id = 0 - - -# ############################################################### -# -# Functions -# -# ############################################################### - -def check_usb_audio(): - "check if usb audio exists" - global device_id - - dev = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID) - if dev is None: - Logger.error('%s: USB AUDIO is not connected' % whoami()) - sendNodeInfo('[***]AUDIO: USB AUDIO ERROR') - device_id = 0 - else: - if device_id > 0 and device_id != dev.address: - Logger.error('%s: USB AUDIO address changed' % whoami()) - device_id = 0 - else: -# Logger.debug('%s: USB AUDIO is connected: %d' % (whoami(), dev.address)) - if device_id != dev.address: sendNodeInfo('[***]AUDIO: USB AUDIO OK') - device_id = dev.address - - return (0 if device_id > 0 else 1) - - -# ############################################################################## -""" -def reset_usb_audio_worker(dt=0): - "reset usb audio board" - "!!!!! USE share/audioini.py !!!!!" - Logger.error('%s: RESET USB AUDIO BOARD' % whoami()) - - VALUE_INI = GPIO.HIGH - VALUE_RST = GPIO.LOW - - GPIO.setmode(GPIO.BCM) - GPIO.setwarnings(False) - GPIO.setup(RST_PIN, GPIO.OUT, initial=VALUE_INI) - - GPIO.output(RST_PIN, VALUE_INI) - sleep(RST_TIME) - GPIO.output(RST_PIN, VALUE_RST) - sleep(RST_TIME) - GPIO.output(RST_PIN, VALUE_INI) - sleep(RST_TIME) -""" - -# ############################################################################## - -def reset_usb_audio(): - "reset usb audio board" - global device_id - - Logger.debug('%s: RESET USB AUDIO BOARD' % whoami()) - sendNodeInfo('[***]AUDIO: USB AUDIO RESET') - - device_id = 0 - - send_command('./audioini.sh') -# threading.Thread(target=reset_usb_audio_worker).start() - - -# ############################################################################## diff --git a/my_lib/callstats.py b/my_lib/callstats.py deleted file mode 100644 index a8d7748..0000000 --- a/my_lib/callstats.py +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -import json -import os - -from kivy.logger import Logger - -from constants import * -from itools import * - - -############################################################### -# -# Declarations -# -# ############################################################### - -PARENT_DIR = '/tmp/' # '/root/indoorpy/logs/' -CALL_CNTR_TMP_FILE = PARENT_DIR + 'call-cntr.dat' -CALL_LOG_TMP_FILE = PARENT_DIR + 'call-log.dat' - -call_statistics = None # call counters -call_log = None # call log for last N calls - - -# ############################################################### -# -# Functions -# -# ############################################################### - -def initcallstat(): - "Call statistics initialization" - global call_statistics, call_log - - Logger.debug('%s:' % (whoami())) - - call_statistics = None - call_log = None - - try: - with open(CALL_CNTR_TMP_FILE, 'r') as data_file: - call_statistics = json.load(data_file) - except: call_statistics = {} - - try: - with open(CALL_LOG_TMP_FILE, 'r') as data_file: - call_log = json.load(data_file) - except: call_log = [] - - # create files if not exists - if call_statistics == {} or call_statistics == None or len(call_statistics) == 0: - call_statistics = {'in':0, 'out':0, 'noansw': 0, 'noresp':0} - try: - with open(CALL_CNTR_TMP_FILE, 'w+') as data_file: - json.dump(call_statistics, data_file) - except Exception: pass - - if call_log == None or len(call_log) == 0: - call_log = [] - try: - with open(CALL_LOG_TMP_FILE, 'w+') as data_file: - json.dump(call_log, data_file) - except Exception: pass - - -# ############################################################################## - -""" -Call state constants: -==================== -0 - NULL -- call is not initialized. -1 - CALLING -- initial INVITE is sent. -2 - INCOMING -- initial INVITE is received. -3 - EARLY -- provisional response has been sent or received. -4 - CONNECTING -- 200/OK response has been sent or received. -5 - CONFIRMED -- ACK has been sent or received. -6 - DISCONNECTED -- call is disconnected. -""" - -STATUS = ['','CALLING','INCOMING','EARLY','CONNECTING','CONFIRM','DISCONNECTED'] - -def setcallstat(outflag=False, status=0, prev_status=0, call=''): - "Increment call stat counters and save to TMP file" - global call_statistics, call_log - - dt = getdatetimestr() - - if status == 0 or status == 4 or ((status == 3) and outflag): return - - Logger.debug('%s: dt=%s outflag=%r state=%d %s (prev=%d %s) call=%s'\ - % (whoami(), dt, outflag, status, STATUS[status], prev_status, STATUS[prev_status], call)) - - #call_statistics = {'in':0, 'out':0, 'noansw': 0, 'noresp':0} - if outflag: - if status == 6: - if prev_status == 5: call_statistics['out'] += 1 - else: call_statistics['noresp'] += 1 - else: - if status == 6: - if prev_status == 5: call_statistics['in'] += 1 - else: call_statistics['noansw'] += 1 - - filename = CALL_CNTR_TMP_FILE - try: - with open(filename, 'w') as data_file: - json.dump(call_statistics, data_file) - except Exception as e:# pass - Logger.error('%s: e=%s' % (whoami(), str(e))) - - typ = 'OUT' if outflag else 'IN ' - rec = '%s %s (%d) %s %s' % (dt, typ, status, STATUS[status], call) - call_log.append(rec) - if len(call_log) > 100: call_log.pop(0) - - filename = CALL_LOG_TMP_FILE - try: - with open(filename, 'w') as data_file: - json.dump(call_log, data_file) - except Exception as e:# pass - Logger.error('%s: e=%s' % (whoami(), str(e))) - - -# ############################################################################## diff --git a/my_lib/classes.py b/my_lib/classes.py deleted file mode 100644 index 0b41191..0000000 --- a/my_lib/classes.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - - -import kivy -kivy.require('1.9.0') - - -from kivy.core.window import Window -from kivy.lang import Builder -from kivy.logger import Logger, LoggerHistory -from kivy.uix.floatlayout import FloatLayout -from kivy.uix.behaviors import ButtonBehavior -from kivy.uix.boxlayout import BoxLayout -from kivy.uix.button import Button -from kivy.uix.image import Image, AsyncImage -from kivy.uix.label import Label -from kivy.uix.listview import ListView, ListItemLabel -from kivy.uix.popup import Popup -from kivy.uix.screenmanager import Screen -from kivy.uix.widget import Widget - -from constants import * - - -mainLayout = None - -# ############################################################### -# -# Classes -# -# ############################################################### - -class SetScreen(Screen): - "setscreen" - pass - - -# ############################################################################## - -class MyListViewLabel(Label): - "debug message item in listview" - pass - - -# ############################################################################## - -class MySetLabel(Label): - "show value near slider" - pass - - -# ############################################################################## - -class VideoLabel(Label): - "text behind the video" - pass - - -# ############################################################################## - -class MyAsyncImage(Image): -#class MyAsyncImage(AsyncImage): - "image class" - pass - - -# ############################################################################## - -class ImageButton(Button): - "button line at the bottom of the page" - pass - - -# ############################################################################## - -class DoorButton(Button): - "four images door lock/unlock button at the bottom of the page" - pass - - -# ############################################################################## - -class MBoxLayout(BoxLayout): - "layout + black color background" - pass - - -# ############################################################################## - -class HorizontalCameraLayout(BoxLayout): - "landscape camera layout" - pass - - -# ############################################################################## - -class VerticalCameraLayout(BoxLayout): - "portrait camera layout" - pass - - -# ############################################################################## - -class SliderArea(MBoxLayout): - "volume slider next to the call window" - pass - - -# ############################################################################## - diff --git a/my_lib/config.py b/my_lib/config.py deleted file mode 100644 index 21ea967..0000000 --- a/my_lib/config.py +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -from kivy.config import Config, ConfigParser -from kivy.logger import Logger - -from constants import * -from itools import * - - -############################################################### -# -# Declarations -# -# ############################################################### - -dict_command = {'screen_saver': 1, - 'dnd_mode': 0, - 'brightness': 100, - 'watches': 'analog' } -dict_sip = {'sip_mode': 'peer-to-peer', - 'sip_server_addr': '', - 'sip_port': '5060', - 'sip_username': '', - 'sip_authentication_name': '', - 'sip_p4ssw0rd': '' } -dict_dev = {'ringtone': 'oldphone.wav', - 'volume': 100, - 'micvolume': 100 } -dict_gui = {'screen_mode': 1, - 'screen_orientation': 0, - 'outgoing_calls': 1 } -dict_common = {'server_ip_address_1': '192.168.1.250', - 'server_stream_1': 'http://192.168.1.250:80/video.mjpg', - 'picture_1': 'fill', - 'sip_call1': '192.168.1.250', - 'server_ip_address_2': '', - 'server_stream_2': 'http://192.168.1.250/video.mjpg', # 'http://192.168.1.241:8080/stream/video.mjpeg', - 'picture_2': 'fill', - 'sip_call2': '', - 'server_ip_address_3': '', - 'server_stream_3': 'http://192.168.1.250/video.mjpg', - 'picture_3': 'fill', - 'sip_call3': '', - 'server_ip_address_4': '', - 'server_stream_4': 'http://192.168.1.250/video.mjpg', - 'picture_4': 'fill', - 'sip_call4': '' } -dict_timezone = {'timezone': 'Europe/Brussels'} -dict_service = {'masterpwd': '1234', - 'app_log': 'error', - 'tunnel_flag': 0, - 'autoupdate': 1, - 'update_repo': 'production', - 'sip_log': 'error' } -dict_about = {'app_name': 'Indoor 2.0', - 'app_ver': '2.0.0.0', - 'licencekey': '0000-000000-0000-000000-0000', - 'regaddress': '', - 'serial': '' } -dict_system = {'inet': 'manual', - 'ipaddress': '192.168.1.251', - 'gateway': '192.168.1.200', - 'netmask': '255.255.255.0', - 'dns': '192.168.1.201' } - - -# ############################################################### -# -# Functions -# -# ############################################################### - -def get_config(): - "nacitanie konfiguracie" - Logger.debug('%s: ' % whoami()) - - config = ConfigParser() - try: - config.read('./' + CONFIG_FILE) - except: - Logger.info('get_config: ERROR 1 - read config file!') - - try: - config.read(dirname(__file__) + '/' + CONFIG_FILE) - except: - Logger.warning('get_config: ERROR 2 - read config file!') - return None - - return config - - -# ############################################################### - -def setDefaultConfig(config, full=False): - "nastavenie konfiguracnych parametrov" - Logger.debug('%s: ' % whoami()) - - config.setdefaults('command', dict_command) - config.setdefaults('sip', dict_sip) - config.setdefaults('devices', dict_dev) - config.setdefaults('gui', dict_gui) - config.setdefaults('common', dict_common) - config.setdefaults('timezones', dict_timezone) - config.setdefaults('service', dict_service) - config.setdefaults('about', dict_about) - config.setdefaults('system', dict_system) - - try: - s = get_info(SYSTEMINFO_SCRIPT).split() - except: - s = [] - - cnt = len(s) - - if cnt > 1: config.set('about', 'serial', s[1]) - - dns = '' - try: - dns = s[8] - except: - dns = '' - - if cnt < 6: - config.set('system', 'inet', 'manual') - config.set('system', 'ipaddress', '127.0.0.1') - config.set('system', 'gateway', '') - config.set('system', 'netmask', '') - config.set('system', 'dns', dns) - else: - config.set('system', 'inet', s[2]) - config.set('system', 'ipaddress', s[3]) - config.set('system', 'gateway', s[6]) - config.set('system', 'netmask', s[4]) - config.set('system', 'dns', dns) - - if full: - config.setall('command', dict_command) - config.setall('sip', dict_sip) - config.setall('devices', dict_dev) - config.setall('gui', dict_gui) - config.setall('common', dict_common) - config.setall('timezones', dict_timezone) - config.setall('service', dict_service) - config.setall('system', dict_system) - - for s in config.sections(): - Logger.info('%s: section=%s' % (whoami(),s)) - for k, v in config.items(s): - Logger.info('%s: key=%s val=%s' % (whoami(), k, v)) - - config.write() - - return config - - -# ############################################################### - -def saveKivyCfg(section, item, value): - "nastavenie konfiguracnych parametrov pre Kivy" - Logger.debug('%s: [%s] %s = %s' % (whoami(), section, item, value)) - - kivycfg = ConfigParser() - try: - kivycfg.read(KIVY_CONFIG_FILE) - kivycfg.set(section, item, value) - kivycfg.write() - except: - Logger.warning('%s: ERROR! ([%s] %s = %s)' % (whoami(), section, item, value)) - - -# ############################################################### diff --git a/my_lib/constants.py b/my_lib/constants.py deleted file mode 100644 index e670251..0000000 --- a/my_lib/constants.py +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/python - -############################################################### -# -# Imports -# -# ############################################################### - -from kivy.graphics import Color - - -############################################################### -# -# Declarations -# -# ############################################################### - -CMD_KILL = 'kill -9 ' - -CONFIG_FILE = 'indoor.ini' # 'indoorconfig.ini' -KIVY_CONFIG_FILE = '/root/.kivy/config.ini' - -APP_NAME = '-Indoor-2.0-' -APP_VERSION_CODE = '2.0.0.4' - -SCREEN_SAVER = 0 -WATCHES = 'analog' -ROTATION = 0 - -# ### scripts: ### -DBUSCONTROL_SCRIPT = './dbuscntrl.sh' -BACK_LIGHT_SCRIPT = './backlight.sh' -UNBLANK_SCRIPT = './unblank.sh' -BRIGHTNESS_SCRIPT = './brightness.sh' -SYSTEMINFO_SCRIPT = './sysinfo.sh' -VOLUMEINFO_SCRIPT = './volumeinfo.sh' -SETVOLUME_SCRIPT = './setvolume.sh' -SETMICVOLUME_SCRIPT = './setmicvolume.sh' -SETIPADDRESS_SCRIPT = './setipaddress.sh' -HIDINIT_SCRIPT = './hid_init.sh' - -# ### images: ### -MAKE_CALL_IMG = 'imgs/ww_phone-call.png' -ANSWER_CALL_IMG = 'imgs/w_call-answer.gif' # 'imgs/w_phone-call.png' -HANGUP_OUTGOING_CALL_IMG = 'imgs/w_call-cancel.gif' -HANGUP_CALL_IMG = 'imgs/w_call-disconnect.png' -ERROR_CALL_IMG = 'imgs/nothing.png' # 'imgs/w_call-reject.png' -DND_CALL_IMG = 'imgs/w_call-dnd.png' -UNUSED_CALL_IMG = 'imgs/nothing.png' # 'imgs/w_call_grey.png' - -VOLUME_IMG = 'imgs/w_speaker.png' -MICROPHONE_IMG = 'imgs/w_microphone.png' - -SCREEN_SAVER_IMG = 'imgs/w_monitor.png' -SETTINGS_IMG = 'imgs/w_settings.png' -LOCK_IMG = 'imgs/w_lock.png' -UNLOCK_IMG = 'imgs/w_unlock.png' -INACTIVE_LOCK_IMG = 'imgs/w_nolock.png' -UNUSED_LOCK_IMG = 'imgs/w_lock_grey.png' - -NO_IMG = 'imgs/nothing.png' - -# ### screens: ### -WAIT_SCR = 'waitscr' -DIGITAL_SCR = 'digiclock' -CAMERA_SCR = 'camera' -SETTINGS_SCR = 'settings' - -# ### colors: ### -COLOR_BUTTON_BASIC = .9,.9,.9,1 -COLOR_ANSWER_CALL = .9,.9,0,1 -COLOR_HANGUP_CALL = 0,0,.9,1 -COLOR_ERROR_CALL = .9,0,0,1 -COLOR_NOMORE_CALL = COLOR_BUTTON_BASIC - -ACTIVE_DISPLAY_BACKGROUND = [1.,1.,1.] #[.0,.0,.9] -INACTIVE_DISPLAY_BACKGROUND = [.3,.3,.3] #[.0,.0,.0] -N0_DISPLAY_BACKGROUND = [.0,.0,.0] - -# ### audio player: ### -APLAYER = 'aplay' -APARAMS = '-q -N -f cd -D plughw:0,0 sounds/' -RING_TONE = 'oldphone.wav' -BUSY_TONE = 'dial.wav' # 'busy.wav' -DIAL_TONE = 'tada.wav' -RING_WAV = APLAYER + ' ' + APARAMS + RING_TONE -BUSY_WAV = APLAYER + ' ' + APARAMS + BUSY_TONE -DIAL_WAV = APLAYER + ' ' + APARAMS + DIAL_TONE - -ring_event = None - -# ### SIP: ### -LOG_LEVEL = 3 #5 # basic SIP log level -current_call = None -acc = None -sipRegStatus = False - -# ### time: ### -ICON_RELOAD = .3 -HIDINIT_TIME = 3. # 4 -PHONEINIT_TIME = HIDINIT_TIME + .2 # 3 - -# ### variables & constatnts: ### -main_state = 0 -docall_button_global = None - -active_display_index = 0 - -TRANSPARENCY_VIDEO_CMD = ['setalpha'] - -DBUS_PLAYERNAME = 'org.mpris.MediaPlayer2.omxplayer' - -mainLayout = None -scrmngr = None -scr_mode = 0 -config = None - -procs = [] - diff --git a/my_lib/inputdlg.py b/my_lib/inputdlg.py deleted file mode 100644 index d73dd07..0000000 --- a/my_lib/inputdlg.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -import kivy -kivy.require('1.9.0') - - -from kivy.lang import Builder -from kivy.logger import Logger, LoggerHistory -from kivy.uix.boxlayout import BoxLayout -from kivy.uix.button import Button -from kivy.uix.image import Image -from kivy.uix.label import Label -from kivy.uix.popup import Popup -from kivy.uix.textinput import TextInput -from kivy.uix.widget import Widget - -from kivy.clock import Clock - -from constants import * -from itools import * - - -# ############################################################### -# -# Popup Class - input text -# -# ############################################################### - -KV = ''' -BoxLayout: - orientation: 'vertical' - lbl1: lbl1 - tin1: tin1 - btno: btno - btok: btok - spacing: '8px' - - Label: - text: '' - id: lbl1 - font_size: 20 - size_hint_y: None - height: '32px' - - TextInput: - text: '' - id: tin1 - multiline: False - size_hint_y: None - font_size: '24px' - height: '40px' - - AsyncImage: - source: 'imgs/nothing.png' - - BoxLayout: - orientation: 'horizontal' - size_hint_y: None - height: 48 - spacing: '8px' - - Button: - text: 'OK' - id: btok - Button: - text: 'Cancel' - id: btno -''' - - -class MyInputBox(Popup): - "Input popup box" - def __init__(self, **kwargs): - super(MyInputBox, self).__init__(**kwargs) - - Logger.debug('%s: titl=$%s msg=%s' % (whoami(),kwargs.get('titl'),kwargs.get('txt'))) - - self.p = Builder.load_string(KV) - self.p.lbl1.text = kwargs.get('txt') or '' - self.p.tin1.text = '' - self.p.tin1.password = kwargs.get('pwd') or False - self.p.btok.bind(on_press=self.buttonOk) - self.p.btno.bind(on_press=self.buttonNo) - - self.title = kwargs.get('titl') - self.auto_dismiss = kwargs.get('ad') or False - self.cb = kwargs.get('cb') or None - self.size_hint = (.6, .5) - self.content = self.p - -# Clock.schedule_once(self.refocus_text_input, .75) - - - def refocus_text_input(self, arg1): - self.p.tin1.focus = True - - - def buttonOk(self, b): - Logger.debug('%s: Yes msg=%s' % (whoami(), self.p.tin1.text)) - - self.dismiss() - if not self.cb is None: self.cb(self.p.tin1.text) - - - def buttonNo(self, b): - Logger.debug('%s: No' % (whoami())) - - self.dismiss() - if not self.cb is None: self.cb('') - - -# ############################################################################## diff --git a/my_lib/itools.py b/my_lib/itools.py deleted file mode 100644 index 4e5799f..0000000 --- a/my_lib/itools.py +++ /dev/null @@ -1,156 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -from kivy.clock import Clock - -import inspect -import os -import signal -import socket -import subprocess -import sys -import time - -from omxcontrol import * -from threading import Thread - -from kivy.logger import Logger - -from constants import * - - -############################################################### -# -# Declarations -# -# ############################################################### - -omxl = {} -ret_dbus = {} - - -# ############################################################### -# -# Functions -# -# ############################################################### - -def whoami(): - "returns name of function" - return inspect.stack()[1][3] - - -# ############################################################################## - -def getdatetimestr(): - t = datetime.datetime.now() - return t.strftime('%Y-%m-%d %H:%M:%S') - - -# ############################################################################## - -def send_dbus(dst,args): - "send DBUS command to omxplayer" - ret_dbus[dst] = False - t = Thread(target=send_dbus_worker, kwargs={'dst': dst, 'args': args}) - t.daemon = True - t.start() - t.join() - return ret_dbus[dst] - - -# ############################################################################## - -def send_dbus_worker(dst,args): - "worker thread: send DBUS command to omxplayer" - - try: - if omxl[dst] is None: omxl[dst] = OmxControl(user='root',name=dst) - except: - try: - omxl[dst] = OmxControl(user='root',name=dst) - except: - Logger.warning('%s: dst=%s args=%r ERROR' % (whoami(), dst, args)) - return True - - omx = omxl[dst] - - try: - if args[0] is 'setalpha': -# v = '1' if '0' is args[1] else '254' -# omx.setAlpha(v) - if '0' == args[1]: omx.action(OmxControl.ACTION_HIDE_VIDEO) - elif '255' == args[1]: omx.action(OmxControl.ACTION_UNHIDE_VIDEO) - else: omx.setAlpha(args[1]) - elif args[0] == 'status': - Logger.info('%s: dst=%s status=%r' % (whoami(), dst, omx.status())) - else: - omx.videoPos(args[1:]) - - ret_dbus[dst] = True - return True - except OmxControlError as ex: - Logger.warning('%s: dst=%s args=%r ERR=%s' % (whoami(), dst, args, ex.message)) - Logger.info('%s: dst=%s properties=%r' % (whoami(), dst, omx.properties())) - - # try to repeat command - try: - time.sleep(1.69) - if args[0] is 'setalpha': - if '0' == args[1]: omx.action(OmxControl.ACTION_HIDE_VIDEO) - elif '255' == args[1]: omx.action(OmxControl.ACTION_UNHIDE_VIDEO) - else: omx.setAlpha(args[1]) - elif args[0] == 'status': - Logger.info('%s: dst=%s status=%r' % (whoami(), dst, omx.status())) - else: - omx.videoPos(args[1:]) - - ret_dbus[dst] = True - return True - except: pass - - return False - - -# ############################################################################## - -def send_command(cmd): - "send shell command" - Logger.debug('%s: cmd=%s' % (whoami(), cmd)) - try: - os.system(cmd) - except: - pass - - -# ############################################################### - -def get_info(cmd): - "get information from shell script" - proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, shell=False) - (out, err) = proc.communicate() - Logger.debug('%s: cmd=%s out=%s (err=%s)' % (whoami(), cmd, out, str(err))) - return out - - -# ############################################################################## - -def getINet(): - "check the Internet connection" - return True ### stop checking - - info = '0' - - try: info = get_info('./checkinet.sh') - except: pass - - return True if '1' in info else False - - -# ############################################################################## - diff --git a/my_lib/loggerpatch.py b/my_lib/loggerpatch.py deleted file mode 100644 index 0c63b9b..0000000 --- a/my_lib/loggerpatch.py +++ /dev/null @@ -1,51 +0,0 @@ -from kivy.logger import Logger -from kivy.clock import Clock - -import logging -import time - -from itools import * -from loggers import * -from nodeclient import * - - -class LoggerPatch(): - - def __init__(self): - self.emit_org = None - - # we create a formatter object once to avoid inialisation on every log line - self.oFormatter=logging.Formatter(None) - - # we just need to patch the first Handler as we change the message itself - oHandler = Logger.handlers[0] - self.emit_org=oHandler.emit - oHandler.emit=self.emit - - initNodeConnection() - - - def emit(self, record): - # we do not use the formatter by purpose as it runs on failure - # if the message string contains format characters - - ct = self.oFormatter.converter(record.created) - t = time.strftime("%Y-%m-%d %H-%M-%S", ct) - t = "%s.%03d" % (t, record.msecs) - - msg = '[%-7s] [%s] %s' % (record.levelname, t, record.msg) - record.msg= t + ': ' + record.msg - - self.emit_org(record) - - Clock.schedule_once(lambda dt: self.save(msg)) - - - def save(self, msg): -# print('%s: %s' % (whoami(), msg)) - setloginfo(False, msg) - - sendNodeInfo(msg) - - -oLoggerPatch = LoggerPatch() \ No newline at end of file diff --git a/my_lib/loggers.py b/my_lib/loggers.py deleted file mode 100644 index 371e2b6..0000000 --- a/my_lib/loggers.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -import json -import os - -from kivy.logger import Logger - -from constants import * -from itools import * - - -############################################################### -# -# Declarations -# -# ############################################################### - -PARENT_DIR = '/tmp/' # '/root/indoorpy/logs/' -APP_LOG_TMP_FILE = PARENT_DIR + 'app-log.dat' -SIP_LOG_TMP_FILE = PARENT_DIR + 'sip-log.dat' - -MAX_APP_CNT = 500 #1000 -MAX_SIP_CNT = 250 - -app_log = [] # log for last N messages -sip_log = [] # log for last N messages - - -# ############################################################### -# -# Functions -# -# ############################################################### - -def initloggers(): - "Loggers initialization" - global app_log, sip_log - - Logger.info('%s:' % whoami()) -# send_command('echo "start" > /tmp/deb.txt') - - app_log = [] - sip_log = [] - - try: - with open(APP_LOG_TMP_FILE, 'r') as data_file: - app_log = json.load(data_file) - except: app_log = [] - - try: - with open(SIP_LOG_TMP_FILE, 'r') as data_file: - sip_log = json.load(data_file) - except: sip_log = [] - - #create files if not exists - if app_log == None or len(app_log) == 0: - app_log = [] - try: - with open(APP_LOG_TMP_FILE, 'w+') as data_file: - json.dump(app_log, data_file) - except: pass - - if sip_log == None or len(sip_log) == 0: - sip_log = [] - try: - with open(SIP_LOG_TMP_FILE, 'w+') as data_file: - json.dump(sip_log, data_file) - except: pass - - -# ############################################################################## - -def setloginfo(sipflag=False, msg=''): - "Save msg to TMP file" - global app_log, sip_log - -# print('%s: dt=%s sipflag=%r msg=%s'% (whoami(), getdatetimestr(), sipflag, msg)) -# if not '/tmp/deb.txt' in msg: send_command('echo "%s" >> /tmp/deb.txt' % msg) - - if sipflag: - sip_log.append('%s %s' % (getdatetimestr(), msg)) - if len(sip_log) > MAX_SIP_CNT: sip_log.pop(0) - filename = SIP_LOG_TMP_FILE - log = sip_log - else: - if '[DEBUG' in msg or '[TRACE' in msg: return - app_log.append(msg) - if len(app_log) > MAX_APP_CNT: app_log.pop(0) - filename = APP_LOG_TMP_FILE - log = app_log - - try: - with open(filename, 'w') as data_file: - json.dump(log, data_file) - except Exception as e: - pass -# print('%s: e=%s' % (whoami(), str(e))) - - -# ############################################################################## diff --git a/my_lib/netlink.py b/my_lib/netlink.py deleted file mode 100644 index 10b3884..0000000 --- a/my_lib/netlink.py +++ /dev/null @@ -1,120 +0,0 @@ - -#!/bin/python - -# ############################################################### -# -# NetLink socket -# -# ############################################################### - -from kivy.logger import Logger - -from itools import * - -import os -import socket -import struct -import time - -netstatus = 1 - -def procNetlink(): - "listen to system NETLINK socket" - global netstatus - - # These constants map to constants in the Linux kernel. This is a crappy - # way to get at them, but it'll do for now. - RTMGRP_LINK = 1 - RTMGRP_IPV4_IFADDR = 0x10 - - NLMSG_NOOP = 1 - NLMSG_ERROR = 2 - - RTM_NEWLINK = 16 - RTM_DELLINK = 17 - RTM_NEWADDR = 20 - RTM_DELADDR = 21 - - IFLA_ADDRESS = 1 - IFLA_IFNAME = 3 - - WAIT_TXT = ' wait...' - OK_TXT = ' OK ' - NO_TXT = ' NO ' - ERR_TXT = ' ERROR ' - NONE_TXT = ' None ' - UP_TXT = ' up ' - DOWN_TXT = ' down ' - - - # Create the netlink socket and bind to RTMGRP_LINK, - s = socket.socket(socket.AF_NETLINK, socket.SOCK_RAW, socket.NETLINK_ROUTE) -# s.bind((os.getpid(), RTMGRP_LINK)) - s.bind((0, -1)) - - old_msg = -1 - link_status = '' - - while True: - time.sleep(.3) - - data = s.recv(65535) - msg_len, msg_type, flags, seq, pid = struct.unpack("=LHHLL", data[:16]) - - if msg_type == NLMSG_NOOP: continue - if msg_type == NLMSG_ERROR: break - - if old_msg == msg_type: continue - - old_msg = msg_type - - # We fundamentally only care about NEWLINK messages in this version. - #if msg_type != RTM_NEWLINK: - if not msg_type in [RTM_NEWLINK, RTM_DELLINK, RTM_NEWADDR, RTM_DELADDR]: continue - - data = data[16:] - - family, _, if_type, index, flags, change = struct.unpack("=BBHiII", data[:16]) - - remaining = msg_len - 32 - data = data[16:] - - while remaining and len(data) >= 4: - rta_len, rta_type = struct.unpack("=HH", data[:4]) - - # This check comes from RTA_OK, and terminates a string of routing attributes. - if rta_len < 4: break - - rta_data = data[4:rta_len] - - increment = (rta_len + 4 - 1) & ~(4 - 1) - data = data[increment:] - remaining -= increment - -# print('%s: %d %s' % (whoami(), msg_type, rta_data)) - - ip = '' - # Hoorah, a link is up! - if msg_type == RTM_NEWLINK: - ip = UP_TXT - netstatus = 1 - elif msg_type == RTM_DELLINK: - ip = DOWN_TXT - netstatus = 0 - elif msg_type == RTM_NEWADDR: - ip = OK_TXT - netstatus = 1 - elif msg_type == RTM_DELADDR: - ip = WAIT_TXT - netstatus = 0 - - if len(ip) == 0: continue - - if rta_type == IFLA_IFNAME and msg_type in [RTM_NEWLINK, RTM_DELLINK]: - if link_status != ip: - link_status = ip - Logger.info('%s: LINK IS %s' % (whoami(), ip)) - continue - elif rta_type == IFLA_IFNAME: - Logger.info('%s: IP ADDRESS IS %s' % (whoami(), ip)) - continue diff --git a/my_lib/nodeclient.py b/my_lib/nodeclient.py deleted file mode 100644 index d5f1dd9..0000000 --- a/my_lib/nodeclient.py +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -from kivy.logger import Logger -from kivy.clock import Clock - -import socket - -from constants import * -from itools import * - - -############################################################### -# -# Declarations -# -# ############################################################### - -RECONNECT_TIMER = 15 - -appSocket = None -address = None -server_port = None -connErr = True - -structEvent = None - -app_status = {'VIDEO':{},'LOCK':{}} # struct to save app status - - -# ############################################################### -# -# Functions -# -# ############################################################### - -def initNodeConnection(addr='localhost', port=8123): - "Build socket connection" - global appSocket, server_port, address, connErr, app_status - - Logger.info('%s: %s:%d' % (whoami(), addr, port)) - - address = addr - server_port = port - - try: - # Create a TCP/IP socket - appSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - - # Connect the socket to the port where the server is listening - server_address = (addr, port) - appSocket.connect(server_address) - connErr = False - Clock.schedule_once(lambda dt: sendNodeInfo('STRUCT:%r' % app_status), 10) - except socket.error, e: - connErr = True - Logger.error('%s ERROR: %r' % (whoami(), e)) - Clock.schedule_once(lambda dt: initNodeConnection(address, server_port), RECONNECT_TIMER) - - -# ############################################################################## - -def sendNodeInfo(msg=''): - "Send msg to node server" - global server_port, address, connErr, app_status - - if '[***]' in msg: - statusInfo(msg[5:]) - else: - if 'STRUCT:' in msg: msg = '[***]%s' % msg - - if connErr: return -# print('%s: %s' % (whoami(), msg)) - - try: - appSocket.sendall(msg.encode()) -## appSocket.send(msg.encode()) - except socket.error: -# print('%s: ERROR' % (whoami())) - connErr = True - Clock.schedule_once(lambda dt: initNodeConnection(address, server_port), RECONNECT_TIMER) - - -# ############################################################################## - -def statusStructInfo(): - "send the status struct info" - global app_status, structEvent - - try: - if structEvent: Clock.unschedule(structEvent) - except : pass - - structEvent = Clock.schedule_once(lambda dt: sendNodeInfo('STRUCT:%r' % app_status), 3) - - -# ############################################################################## - -def statusInfo(info): - "put info to the status struct" - global app_status - - try: - a = info.split(':', 2) - if len(a) > 1: - a[0] = a[0].strip() - #if a[0][0] == 'u': a[0] = a[0][1:] - a[1] = a[1].strip() - #if a[1][0] == 'u': a[1] = a[1][1:] - if 'LOCK' in a[0] or 'VIDEO' in a[0]: - b = a[1].strip().split(' ', 2) - if len(b) > 1: app_status[a[0]][b[0]] = b[1].strip() - else: app_status[a[0]] = a[1] - else: - app_status[a[0]] = a[1] - - statusStructInfo() - except: pass - - Logger.trace('%s: %r' % (whoami(), app_status)) - - -# ############################################################################## diff --git a/my_lib/registration.py b/my_lib/registration.py deleted file mode 100644 index b2d669f..0000000 --- a/my_lib/registration.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -#import datetime - -import urllib -import urllib2 - -from kivy.logger import Logger - -from constants import * -from itools import * - - -############################################################### -# -# Declarations -# -# ############################################################### - - -REGISTRATION_URL_ADDRESS = 'http://livebackups.inoteska.sk/' -REGISTRATION_PATH = 'licences.php' - - -# ############################################################### -# -# Functions -# -# ############################################################### - -def send_regs_request(dst, args): - "send registration request to obtain licence key" - - dt = getdatetimestr() - - url = dst + REGISTRATION_PATH - values = {'sn' : args[0], 'email' : args[1], 'lk' : args[2], 'date' : dt } - - data = urllib.urlencode(values) - req = urllib2.Request(url, data) - try: - response = urllib2.urlopen(req) - rsp = response.read() - Logger.info('%s: dst=%s args=[%s,%s] >> rsp=%s' % (whoami(), dst, ','.join(args), dt, rsp)) - - return rsp - except URLError as e: - Logger.warning('%s: dst=%s args=[%s,%s] ERR=%s' % (whoami(), dst, ','.join(args), dt, str(e))) - return 'Error' - - -# ############################################################################## diff --git a/my_lib/settingsbutton.py b/my_lib/settingsbutton.py deleted file mode 100644 index 2b55cb4..0000000 --- a/my_lib/settingsbutton.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -from kivy.uix.button import Button -from kivy.uix.settings import SettingItem -""" -from kivy.uix.togglebutton import ToggleButton -from kivy.uix.gridlayout import GridLayout -from kivy.uix.scrollview import ScrollView -from kivy.uix.popup import Popup -from kivy.uix.settings import Settings, SettingOptions, SettingSpacer -from kivy.uix.widget import Widget -""" - - -# ############################################################### -# -# Declarations -# -# ############################################################### - -class SettingButtons(SettingItem): - - def __init__(self, **kwargs): - self.register_event_type('on_release') - - super(SettingItem, self).__init__(**kwargs) - - for aButton in kwargs["buttons"]: - oButton = Button(text=aButton['title'], font_size='15sp') - oButton.ID = aButton['id'] - self.add_widget(oButton) - oButton.bind(on_release=self.On_ButtonPressed) - - - def set_value(self, section, key, value): - # set_value normally reads the configparser values and runs on an error - # to do nothing here - return - - - def On_ButtonPressed(self,instance): - self.panel.settings.dispatch('on_config_change',self.panel.config, self.section, self.key, instance.ID) - - -# ############################################################### -""" -class SettingScrollOptions(SettingOptions): - - def _create_popup(self, instance): - "create the popup" - - content = GridLayout(cols=1, spacing='5dp') - scrollview = ScrollView( do_scroll_x=False) - scrollcontent = GridLayout(cols=1, spacing='5dp', size_hint=(None, None)) - scrollcontent.bind(minimum_height=scrollcontent.setter('height')) - self.popup = popup = Popup(content=content, title=self.title, size_hint=(0.5, 0.9), auto_dismiss=False) - - # we need to open the popup first to get the metrics - popup.open() - - # Add some space on top - content.add_widget(Widget(size_hint_y=None, height=2)) - - # add all the options - uid = str(self.uid) - for option in self.options: - state = 'down' if option == self.value else 'normal' - btn = ToggleButton(text=option, state=state, group=uid, size=(popup.width, 55), size_hint=(None, None)) - btn.bind(on_release=self._set_option) - scrollcontent.add_widget(btn) - - # finally, add a cancel button to return on the previous panel - scrollview.add_widget(scrollcontent) - content.add_widget(scrollview) - content.add_widget(SettingSpacer()) - btn = Button(text='Cancel', size=(popup.width, 50),size_hint=(0.9, None)) - btn.bind(on_release=popup.dismiss) - content.add_widget(btn) -""" - diff --git a/my_lib/settingsdlg.py b/my_lib/settingsdlg.py deleted file mode 100644 index c8e3181..0000000 --- a/my_lib/settingsdlg.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - - -import kivy -kivy.require('1.9.0') - - -from kivy.core.window import Window -from kivy.lang import Builder -from kivy.logger import Logger, LoggerHistory -from kivy.uix.floatlayout import FloatLayout -from kivy.uix.behaviors import ButtonBehavior -from kivy.uix.boxlayout import BoxLayout -from kivy.uix.button import Button -from kivy.uix.image import Image -from kivy.uix.label import Label -from kivy.uix.listview import ListView, ListItemLabel -from kivy.uix.popup import Popup -from kivy.uix.screenmanager import Screen -from kivy.uix.widget import Widget - -from config import * -from constants import * -from itools import * - - -mainLayout = None - -# ############################################################### -# -# Classes -# -# ############################################################### - -class SettingsPopupDlg(BoxLayout): - "settings popup content" - def __init__(self, **kwargs): - super(BoxLayout, self).__init__(**kwargs) -# self.music = self.ids.setline3.subbox2.musicspinner -# self.clock = self.ids.setline3.subbox2.clockspinner -# self.music = spinner.bind(text=self.show_selected_value) -# self.clock = spinner.bind(text=self.show_selected_value) - - def closePopupSettings(self): - global mainLayout - mainLayout.closePopupSettings() - mainLayout.showPlayers() - - def openDetailSettings(self): - global mainLayout - mainLayout.closePopupSettings(False) - mainLayout.openAppSettings() - - def brightslider(self): - val = self.setline2.subbox1.brightslider.value - Logger.info('%s: %d' % (whoami(), val)) - send_command('%s %d' % (BRIGHTNESS_SCRIPT, val)) - return val - - def show_selected_value(self,spinner,text): - Logger.info('%s: %r %s' % (whoami(), spinner, text)) - - -# ############################################################################## - diff --git a/my_lib/settingsjson.py b/my_lib/settingsjson.py deleted file mode 100644 index 764b261..0000000 --- a/my_lib/settingsjson.py +++ /dev/null @@ -1,378 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -import json - - -# ############################################################### -# -# Declarations -# -# ############################################################### - -# basic app settings -#settings_app = json.dumps([ -# {'type': 'title', -# 'title': 'Basic application parameters'}, -# {'type': 'numeric', -# 'title': 'Screen saver', -# 'desc': 'Select time to swap do screen saver mode (0-45 min)', -# 'section': 'command', -# 'key': 'screen_saver'}, -# {'type': 'options', -# 'title': 'Watches', -# 'desc': 'Choose if you want to analog or digital watches', -# 'section': 'command', -# 'key': 'watches', -# 'options': ['analog','digital','none']} -#]) - -# ############################################################### - -# set GUI -settings_gui = json.dumps([ - {'type': 'title', - 'title': 'User interface parameters'}, - {'type': 'options', - 'title': 'Screen mode', - 'desc': 'Choose for the display option', - 'section': 'gui', - 'key': 'screen_mode', - 'options': ['1', '2', '4']}, - {'type': 'options', - 'title': 'Rotate', - 'desc': 'Choose for the display orientation', - 'section': 'gui', - 'key': 'screen_orientation', - 'options': ['0', '90', '180', '270']}, - {'type': 'bool', - 'title': 'Outgoing calls', - 'desc': 'Enable/disable outgoing calls', - 'section': 'gui', - 'key': 'outgoing_calls'} -]) - -# ############################################################### - -# set outdoor devices -settings_outdoor = json.dumps([ - {'type': 'title', - 'title': 'Outdoor devices parameters'}, - {'type': 'string', - 'title': 'Device address 1', - 'desc': 'Enter IP address for relay control', - 'section': 'common', - 'key': 'server_ip_address_1'}, - {'type': 'string', - 'title': 'SIP call 1', - 'desc': 'Type SIP call number or IP address', - 'section': 'common', - 'key': 'sip_call1'}, - {'type': 'string', - 'title': 'Stream address 1', - 'desc': 'Enter address to retrieve video stream', - 'section': 'common', - 'key': 'server_stream_1'}, - {'type': 'options', - 'title': 'Aspect ratio 1', - 'desc': 'Choose how to display the picture', - 'section': 'common', - 'key': 'picture_1', - 'options': ['fill', '4:3', '16:9']}, - {'type': 'string', - 'title': 'Device address 2', - 'desc': 'Enter IP address for relay control', - 'section': 'common', - 'key': 'server_ip_address_2'}, - {'type': 'string', - 'title': 'SIP call 2', - 'desc': 'Type SIP call number or IP address', - 'section': 'common', - 'key': 'sip_call2'}, - {'type': 'string', - 'title': 'Stream address 2', - 'desc': 'Enter address to retrieve video stream', - 'section': 'common', - 'key': 'server_stream_2'}, - {'type': 'options', - 'title': 'Aspect ratio 2', - 'desc': 'Choose how to display the picture', - 'section': 'common', - 'key': 'picture_2', - 'options': ['fill', '4:3', '16:9']}, - {'type': 'string', - 'title': 'Device address 3', - 'desc': 'Enter IP address for relay control', - 'section': 'common', - 'key': 'server_ip_address_3'}, - {'type': 'string', - 'title': 'SIP call 3', - 'desc': 'Type SIP call number or IP address', - 'section': 'common', - 'key': 'sip_call3'}, - {'type': 'string', - 'title': 'Stream address 3', - 'desc': 'Enter address to retrieve video stream', - 'section': 'common', - 'key': 'server_stream_3'}, - {'type': 'options', - 'title': 'Aspect ratio 3', - 'desc': 'Choose how to display the picture', - 'section': 'common', - 'key': 'picture_3', - 'options': ['fill', '4:3', '16:9']}, - {'type': 'string', - 'title': 'Device address 4', - 'desc': 'Enter IP address for relay control', - 'section': 'common', - 'key': 'server_ip_address_4'}, - {'type': 'string', - 'title': 'SIP call 4', - 'desc': 'Type SIP call number or IP address', - 'section': 'common', - 'key': 'sip_call4'}, - {'type': 'string', - 'title': 'Stream address 4', - 'desc': 'Enter address to retrieve video stream', - 'section': 'common', - 'key': 'server_stream_4'}, - {'type': 'options', - 'title': 'Aspect ratio 4', - 'desc': 'Choose how to display the picture', - 'section': 'common', - 'key': 'picture_4', - 'options': ['fill', '4:3', '16:9']} -]) - -# ############################################################### - -# audio settings -settings_audio = json.dumps([ - {'type': 'title', - 'title': 'Ring tone and volume settings'}, - {'type': 'options', - 'title': 'Ringtone', - 'desc': 'Choose ringtone', - 'section': 'devices', - 'key': 'ringtone', - 'options': ['oldphone.wav', 'tone1.wav', 'tone2.wav']} -]) - -# ############################################################### - -# SIP settings -settings_sip = json.dumps([ - {'type': 'title', - 'title': 'SIP parameters'}, - {'type': 'options', - 'title': 'SIP mode', - 'desc': 'Choose SIP account type', - 'section': 'sip', - 'key': 'sip_mode', - 'options': ['peer-to-peer', 'SIP server']}, - {'type': 'string', - 'title': 'SIP server address', - 'desc': 'Type SIP server address', - 'section': 'sip', - 'key': 'sip_server_addr'}, - {'type': 'string', - 'title': 'SIP server port', - 'desc': 'Type SIP server port', - 'section': 'sip', - 'key': 'sip_port'}, - {'type': 'string', - 'title': 'SIP user name', - 'desc': 'Type SIP account name', - 'section': 'sip', - 'key': 'sip_username'}, - {'type': 'string', - 'title': 'SIP authentication name', - 'desc': 'Type SIP account authentication name', - 'section': 'sip', - 'key': 'sip_authentication_name'}, - {'type': 'string', - 'title': 'SIP password', - 'desc': 'Type SIP password', - 'section': 'sip', - 'key': 'sip_p4ssw0rd'}, - {"type": "buttons", - "title": "Call log","desc": "View SIP activities", - "section": "sip", - "key": "buttoncalllog", - "buttons": [{"title":"Call Log","id":"button_calllog"}]} -# {'type': 'string', -# 'title': 'SIP ident address', -# 'desc': 'Type SIP ident address', -# 'section': 'sip', -# 'key': 'sip_ident_addr'}, -# {'type': 'string', -# 'title': 'SIP ident info', -# 'desc': 'Type SIP ident info', -# 'section': 'sip', -# 'key': 'sip_ident_info'}, -# {'type': 'string', -# 'title': 'STUNT server', -# 'desc': 'Type STUNT server address', -# 'section': 'sip', -# 'key': 'sip_stun_server'} -]) - -# ############################################################### - -# System parameters -settings_system = json.dumps([ - {'type': 'title', - 'title': 'Network parameters'}, - {'type': 'options', - 'title': 'inet type', - 'desc': 'Choose IP address type', - 'section': 'system', - 'key': 'inet', - 'options': ['static', 'dhcp']}, - {'type': 'string', - 'title': 'IP address', - 'desc': 'Enter Indoor monitor IP address', - 'section': 'system', - 'key': 'ipaddress'}, - {'type': 'string', - 'title': 'Gateway', - 'desc': 'Enter gateway address', - 'section': 'system', - 'key': 'gateway'}, - {'type': 'string', - 'title': 'Network mask', - 'desc': 'Enter netmask address', - 'section': 'system', - 'key': 'netmask'}, - {'type': 'string', - 'title': 'DNS server', - 'desc': 'Type DNS server address', - 'section': 'system', - 'key': 'dns'} -]) - -# ############################################################### - -# about app -settings_about = json.dumps([ - {'type': 'title', - 'title': 'About application'}, - {'type': 'string', - 'title': 'Name', - 'desc': 'The application name to display', - 'section': 'about', - 'disabled': True, - 'key': 'app_name'}, - {'type': 'string', - 'title': 'Version', - 'desc': 'The application version to display', - 'section': 'about', - 'disabled': True, - 'key': 'app_ver'}, - {'type': 'string', - 'title': 'Serial number', - 'desc': 'Indoor monitor serial number', - 'section': 'about', - 'disabled': True, - 'key': 'serial'}, - {'type': 'string', - 'title': 'Licence key', - 'desc': 'Application licence key', - 'section': 'about', - 'disabled': False, - 'key': 'licencekey'}, - {'type': 'string', - 'title': 'Registration email address', - 'desc': 'Enter valid email address to obtain the application licence key', - 'section': 'about', - 'disabled': False, - 'key': 'regaddress'}, - {"type": "buttons", - "title": "Send registration request","desc": "Send registration request to obtain the licence key", - "section": "about", - "key": "buttonregs", - "buttons": [{"title":"Registration","id":"button_regs"}]} -]) - -# ############################################################### - -# service function -timezone_settings = json.dumps([ - {'type': 'title', - 'title': 'Timezone settings'}, - {'type': 'timezone', - 'title': 'Timezone', - 'desc': 'Choose time zone', - 'section': 'timezones', - 'key': 'timezone', - 'options': []} -]) - -# ############################################################### - -# service function -settings_services = json.dumps([ - {'type': 'title', - 'title': 'Service functions'}, - {'type': 'string', - 'title': 'Master password', - 'desc': 'Enter password for input to the detail settings', - 'section': 'service', - 'key': 'masterpwd'}, - {"type": "buttons", - "title": "Status","desc": "Show popup window with main status informations", - "section": "service", - "key": "buttonpress", - "buttons": [{"title":"Status","id":"button_status"}]}, -# {'type': 'options', -# 'title': 'App logging level', -# 'desc': 'Choose level for application logging messages', -# 'section': 'service', -# 'disabled': True, -# 'key': 'app_log', -# 'options': ['debug', 'info', 'error']}, -# {'type': 'options', -# 'title': 'SIP logging level', -# 'desc': 'Choose level for SIP logging messages', -# 'section': 'service', -# 'key': 'sip_log', -# 'disabled': True, -# 'options': ['debug', 'info', 'error']}, -# {"type": "bool", -# "title": "Remote access", -# "desc": "Enable/disable remote connection", -# "section": "service", -# "key": "tunnel_flag"}, - {"type": "buttons", - "title": "Log history","desc": "Show popup window with last 100 log messages", - "section": "service", - "key": "buttonlogs", - "buttons": [{"title":"Log Msg","id":"button_loghist"}]}, - {"type": "buttons", - "title": "Restart","desc": "Restart the application", - "section": "service", - "key": "app_rst", - "buttons": [{"title":"Restart App","id":"button_app_rst"}]}, - {"type": "buttons", - "title": "Factory reset","desc": "Set configuration to default", - "section": "service", - "key": "buttonfactory", - "buttons": [{"title":"Rst Cfg","id":"button_factory"}]}, - {"type": "buttons", - "title": "Update","desc": "Update the application", - "section": "service", - "key": "app_upd", - "buttons": [{"title":"Update App","id":"button_app_upd"}]}, #,{"title":"Del","id":"button_delete"},{"title":"Rename","id":"button_rename"}]} - {'type': 'bool', - 'title': 'AutoUpdate', - 'desc': 'Install updates automatically', - 'section': 'service', - 'key': 'autoupdate'} -]) - -# ############################################################### diff --git a/my_lib/settingssip.py b/my_lib/settingssip.py deleted file mode 100644 index d4c9a04..0000000 --- a/my_lib/settingssip.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -import pjsua as pj - -from kivy.logger import Logger - - -# ############################################################### -# -# Functions -# -# ############################################################### - -def setMediaConfig(): - "pjSip media configuration" - mc = pj.MediaConfig() - - mc.quality = 0 #6 #8 - mc.ec_tail_len = 0 #200 - mc.clock_rate = 48000 #44100 #16000 - Logger.warning('pjSip setMediaConfig: quality:%d ec_tail_len:%d clock_rater:%d'\ - % (mc.quality, mc.ec_tail_len, mc.clock_rate)) - return mc - - -# ############################################################### - -def log_cb(level, str, len): - "pjSip logging callback" - Logger.info('pjSip cb: (%d) %s' % (level, str)) - - -# ############################################################### diff --git a/my_lib/sw_watchdog.py b/my_lib/sw_watchdog.py deleted file mode 100644 index f8c2868..0000000 --- a/my_lib/sw_watchdog.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -import os -import time - -from kivy.logger import Logger - -from itools import * - - -############################################################### -# -# Declarations -# -# ############################################################### - -SW_WD_PATH = '/tmp/indoor_wd.dat' -SW_WD_TIME = 5.01 -wd_val = 0 - - -# ############################################################### -# -# Functions -# -# ############################################################### - -def init_sw_watchdog(): - "SW watchdoq" - global wd_val - - Logger.debug('%s:' % whoami()) - - wd_val = 0 - ln = '' - - try: - with open(SW_WD_PATH, "r+") as text_file: - ln = text_file.read() - except: - pass - - if len(ln) > 0 and not ln.isdigit(): - Logger.critical('%s: RESTART REASON: %s' % (whoami(), ln)) - - -# ############################################################################## - -def sw_watchdog(dt=0): - "SW watchdoq" - global wd_val - - Logger.trace('%s: %d' % (whoami(), wd_val)) - - wd_val = 1 if wd_val > 99 else wd_val + 1 - #if wd_val > 10: return - - with open(SW_WD_PATH, "w+") as text_file: - text_file.write("%02d" % wd_val) - - -# ############################################################################## - -def stop_sw_watchdog(): - "SW watchdoq" - global wd_val - - Logger.debug('%s:' % whoami()) - - wd_val = 0 - - ln = '' - - try: - with open(SW_WD_PATH, "r+") as text_file: - ln = text_file.read() - except: - pass - - if len(ln) > 0 and ln.isdigit(): - with open(SW_WD_PATH, "w+") as text_file: - text_file.write("") - - -# ############################################################################## diff --git a/my_lib/timezonejson.py b/my_lib/timezonejson.py deleted file mode 100644 index 4cf15f7..0000000 --- a/my_lib/timezonejson.py +++ /dev/null @@ -1,191 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - - -from kivy.adapters.listadapter import ListAdapter -from kivy.uix.boxlayout import BoxLayout -from kivy.uix.button import Button -from kivy.uix.floatlayout import FloatLayout -from kivy.uix.listview import ListItemButton, ListView -from kivy.uix.popup import Popup -from kivy.uix.settings import Settings, SettingsWithSidebar, SettingString, SettingSpacer -from kivy.uix.widget import Widget - -from kivy.logger import Logger - -from itools import * - -from operator import itemgetter - - -# ############################################################### -# -# Declarations -# -# ############################################################### - -timezones_json = {"Africa/Abidjan":0,"Africa/Accra":0,"Africa/Addis_Ababa":180,"Africa/Algiers":60,"Africa/Asmara":180,"Africa/Asmera":180,"Africa/Bamako":0,"Africa/Bangui":60,"Africa/Banjul":0,"Africa/Bissau":0,"Africa/Blantyre":120,"Africa/Brazzaville":60,"Africa/Bujumbura":120,"Africa/Cairo":120,"Africa/Casablanca":60,"Africa/Ceuta":120,"Africa/Conakry":0,"Africa/Dakar":0,"Africa/Dar_es_Salaam":180,"Africa/Djibouti":180,"Africa/Douala":60,"Africa/El_Aaiun":60,"Africa/Freetown":0,"Africa/Gaborone":120,"Africa/Harare":120,"Africa/Johannesburg":120,"Africa/Juba":180,"Africa/Kampala":180,"Africa/Khartoum":180,"Africa/Kigali":120,"Africa/Kinshasa":60,"Africa/Lagos":60,"Africa/Libreville":60,"Africa/Lome":0,"Africa/Luanda":60,"Africa/Lubumbashi":120,"Africa/Lusaka":120,"Africa/Malabo":60,"Africa/Maputo":120,"Africa/Maseru":120,"Africa/Mbabane":120,"Africa/Mogadishu":180,"Africa/Monrovia":0,"Africa/Nairobi":180,"Africa/Ndjamena":60,"Africa/Niamey":60,"Africa/Nouakchott":0,"Africa/Ouagadougou":0,"Africa/Porto-Novo":60,"Africa/Sao_Tome":0,"Africa/Timbuktu":0,"Africa/Tripoli":120,"Africa/Tunis":60,"Africa/Windhoek":60,"America/Adak":-540,"America/Anchorage":-480,"America/Anguilla":-240,"America/Antigua":-240,"America/Araguaina":-180,"America/Argentina/Buenos_Aires":-180,"America/Argentina/Catamarca":-180,"America/Argentina/ComodRivadavia":-180,"America/Argentina/Cordoba":-180,"America/Argentina/Jujuy":-180,"America/Argentina/La_Rioja":-180,"America/Argentina/Mendoza":-180,"America/Argentina/Rio_Gallegos":-180,"America/Argentina/Salta":-180,"America/Argentina/San_Juan":-180,"America/Argentina/San_Luis":-180,"America/Argentina/Tucuman":-180,"America/Argentina/Ushuaia":-180,"America/Aruba":-240,"America/Asuncion":-240,"America/Atikokan":-300,"America/Atka":-540,"America/Bahia":-180,"America/Bahia_Banderas":-300,"America/Barbados":-240,"America/Belem":-180,"America/Belize":-360,"America/Blanc-Sablon":-240,"America/Boa_Vista":-240,"America/Bogota":-300,"America/Boise":-360,"America/Buenos_Aires":-180,"America/Cambridge_Bay":-360,"America/Campo_Grande":-240,"America/Cancun":-300,"America/Caracas":-270,"America/Catamarca":-180,"America/Cayenne":-180,"America/Cayman":-300,"America/Chicago":-300,"America/Chihuahua":-360,"America/Coral_Harbour":-300,"America/Cordoba":-180,"America/Costa_Rica":-360,"America/Creston":-420,"America/Cuiaba":-240,"America/Curacao":-240,"America/Danmarkshavn":0,"America/Dawson":-420,"America/Dawson_Creek":-420,"America/Denver":-360,"America/Detroit":-240,"America/Dominica":-240,"America/Edmonton":-360,"America/Eirunepe":-300,"America/El_Salvador":-360,"America/Ensenada":-420,"America/Fort_Wayne":-240,"America/Fortaleza":-180,"America/Glace_Bay":-180,"America/Godthab":-120,"America/Goose_Bay":-180,"America/Grand_Turk":-240,"America/Grenada":-240,"America/Guadeloupe":-240,"America/Guatemala":-360,"America/Guayaquil":-300,"America/Guyana":-240,"America/Halifax":-180,"America/Havana":-240,"America/Hermosillo":-420,"America/Indiana/Indianapolis":-240,"America/Indiana/Knox":-300,"America/Indiana/Marengo":-240,"America/Indiana/Petersburg":-240,"America/Indiana/Tell_City":-300,"America/Indiana/Vevay":-240,"America/Indiana/Vincennes":-240,"America/Indiana/Winamac":-240,"America/Indianapolis":-240,"America/Inuvik":-360,"America/Iqaluit":-240,"America/Jamaica":-300,"America/Jujuy":-180,"America/Juneau":-480,"America/Kentucky/Louisville":-240,"America/Kentucky/Monticello":-240,"America/Knox_IN":-300,"America/Kralendijk":-240,"America/La_Paz":-240,"America/Lima":-300,"America/Los_Angeles":-420,"America/Louisville":-240,"America/Lower_Princes":-240,"America/Maceio":-180,"America/Managua":-360,"America/Manaus":-240,"America/Marigot":-240,"America/Martinique":-240,"America/Matamoros":-300,"America/Mazatlan":-360,"America/Mendoza":-180,"America/Menominee":-300,"America/Merida":-300,"America/Metlakatla":-480,"America/Mexico_City":-300,"America/Miquelon":-120,"America/Moncton":-180,"America/Monterrey":-300,"America/Montevideo":-180,"America/Montreal":-240,"America/Montserrat":-240,"America/Nassau":-240,"America/New_York":-240,"America/Nipigon":-240,"America/Nome":-480,"America/Noronha":-120,"America/North_Dakota/Beulah":-300,"America/North_Dakota/Center":-300,"America/North_Dakota/New_Salem":-300,"America/Ojinaga":-360,"America/Panama":-300,"America/Pangnirtung":-240,"America/Paramaribo":-180,"America/Phoenix":-420,"America/Port-au-Prince":-240,"America/Port_of_Spain":-240,"America/Porto_Acre":-300,"America/Porto_Velho":-240,"America/Puerto_Rico":-240,"America/Rainy_River":-300,"America/Rankin_Inlet":-300,"America/Recife":-180,"America/Regina":-360,"America/Resolute":-300,"America/Rio_Branco":-300,"America/Rosario":-180,"America/Santa_Isabel":-420,"America/Santarem":-180,"America/Santiago":-180,"America/Santo_Domingo":-240,"America/Sao_Paulo":-180,"America/Scoresbysund":0,"America/Shiprock":-360,"America/Sitka":-480,"America/St_Barthelemy":-240,"America/St_Johns":-150,"America/St_Kitts":-240,"America/St_Lucia":-240,"America/St_Thomas":-240,"America/St_Vincent":-240,"America/Swift_Current":-360,"America/Tegucigalpa":-360,"America/Thule":-180,"America/Thunder_Bay":-240,"America/Tijuana":-420,"America/Toronto":-240,"America/Tortola":-240,"America/Vancouver":-420,"America/Virgin":-240,"America/Whitehorse":-420,"America/Winnipeg":-300,"America/Yakutat":-480,"America/Yellowknife":-360,"Antarctica/Casey":480,"Antarctica/Davis":420,"Antarctica/DumontDUrville":600,"Antarctica/Macquarie":660,"Antarctica/Mawson":300,"Antarctica/McMurdo":720,"Antarctica/Palmer":-180,"Antarctica/Rothera":-180,"Antarctica/South_Pole":720,"Antarctica/Syowa":180,"Antarctica/Troll":120,"Antarctica/Vostok":360,"Arctic/Longyearbyen":120,"Asia/Aden":180,"Asia/Almaty":360,"Asia/Amman":180,"Asia/Anadyr":720,"Asia/Aqtau":300,"Asia/Aqtobe":300,"Asia/Ashgabat":300,"Asia/Ashkhabad":300,"Asia/Baghdad":180,"Asia/Bahrain":180,"Asia/Baku":300,"Asia/Bangkok":420,"Asia/Beirut":180,"Asia/Bishkek":360,"Asia/Brunei":480,"Asia/Calcutta":330,"Asia/Chita":480,"Asia/Choibalsan":480,"Asia/Chongqing":480,"Asia/Chungking":480,"Asia/Colombo":330,"Asia/Dacca":360,"Asia/Damascus":180,"Asia/Dhaka":360,"Asia/Dili":540,"Asia/Dubai":240,"Asia/Dushanbe":300,"Asia/Gaza":180,"Asia/Harbin":480,"Asia/Hebron":180,"Asia/Ho_Chi_Minh":420,"Asia/Hong_Kong":480,"Asia/Hovd":420,"Asia/Irkutsk":480,"Asia/Istanbul":180,"Asia/Jakarta":420,"Asia/Jayapura":540,"Asia/Jerusalem":180,"Asia/Kabul":270,"Asia/Kamchatka":720,"Asia/Karachi":300,"Asia/Kashgar":360,"Asia/Kathmandu":345,"Asia/Katmandu":345,"Asia/Khandyga":540,"Asia/Kolkata":330,"Asia/Krasnoyarsk":420,"Asia/Kuala_Lumpur":480,"Asia/Kuching":480,"Asia/Kuwait":180,"Asia/Macao":480,"Asia/Macau":480,"Asia/Magadan":600,"Asia/Makassar":480,"Asia/Manila":480,"Asia/Muscat":240,"Asia/Nicosia":180,"Asia/Novokuznetsk":420,"Asia/Novosibirsk":360,"Asia/Omsk":360,"Asia/Oral":300,"Asia/Phnom_Penh":420,"Asia/Pontianak":420,"Asia/Pyongyang":540,"Asia/Qatar":180,"Asia/Qyzylorda":360,"Asia/Rangoon":390,"Asia/Riyadh":180,"Asia/Saigon":420,"Asia/Sakhalin":600,"Asia/Samarkand":300,"Asia/Seoul":540,"Asia/Shanghai":480,"Asia/Singapore":480,"Asia/Srednekolymsk":660,"Asia/Taipei":480,"Asia/Tashkent":300,"Asia/Tbilisi":240,"Asia/Tehran":270,"Asia/Tel_Aviv":180,"Asia/Thimbu":360,"Asia/Thimphu":360,"Asia/Tokyo":540,"Asia/Ujung_Pandang":480,"Asia/Ulaanbaatar":480,"Asia/Ulan_Bator":480,"Asia/Urumqi":360,"Asia/Ust-Nera":600,"Asia/Vientiane":420,"Asia/Vladivostok":600,"Asia/Yakutsk":540,"Asia/Yekaterinburg":300,"Asia/Yerevan":240,"Atlantic/Azores":0,"Atlantic/Bermuda":-180,"Atlantic/Canary":60,"Atlantic/Cape_Verde":-60,"Atlantic/Faeroe":60,"Atlantic/Faroe":60,"Atlantic/Jan_Mayen":120,"Atlantic/Madeira":60,"Atlantic/Reykjavik":0,"Atlantic/South_Georgia":-120,"Atlantic/St_Helena":0,"Atlantic/Stanley":-180,"Australia/ACT":600,"Australia/Adelaide":570,"Australia/Brisbane":600,"Australia/Broken_Hill":570,"Australia/Canberra":600,"Australia/Currie":600,"Australia/Darwin":570,"Australia/Eucla":525,"Australia/Hobart":600,"Australia/LHI":630,"Australia/Lindeman":600,"Australia/Lord_Howe":630,"Australia/Melbourne":600,"Australia/NSW":600,"Australia/North":570,"Australia/Perth":480,"Australia/Queensland":600,"Australia/South":570,"Australia/Sydney":600,"Australia/Tasmania":600,"Australia/Victoria":600,"Australia/West":480,"Australia/Yancowinna":570,"Brazil/Acre":-300,"Brazil/DeNoronha":-120,"Brazil/East":-180,"Brazil/West":-240,"Canada/Atlantic":-180,"Canada/Central":-300,"Canada/East-Saskatchewan":-360,"Canada/Eastern":-240,"Canada/Mountain":-360,"Canada/Newfoundland":-150,"Canada/Pacific":-420,"Canada/Saskatchewan":-360,"Canada/Yukon":-420,"Chile/Continental":-180,"Chile/EasterIsland":-300,"Etc/GMT":0,"Etc/GMT+0":0,"Etc/GMT+1":-60,"Etc/GMT+10":-600,"Etc/GMT+11":-660,"Etc/GMT+12":-720,"Etc/GMT+2":-120,"Etc/GMT+3":-180,"Etc/GMT+4":-240,"Etc/GMT+5":-300,"Etc/GMT+6":-360,"Etc/GMT+7":-420,"Etc/GMT+8":-480,"Etc/GMT+9":-540,"Etc/GMT-0":0,"Etc/GMT-1":60,"Etc/GMT-10":600,"Etc/GMT-11":660,"Etc/GMT-12":720,"Etc/GMT-13":780,"Etc/GMT-14":840,"Etc/GMT-2":120,"Etc/GMT-3":180,"Etc/GMT-4":240,"Etc/GMT-5":300,"Etc/GMT-6":360,"Etc/GMT-7":420,"Etc/GMT-8":480,"Etc/GMT-9":540,"Etc/GMT0":0,"Etc/Greenwich":0,"Etc/UCT":0,"Etc/UTC":0,"Etc/Universal":0,"Etc/Zulu":0,"Europe/Amsterdam":120,"Europe/Andorra":120,"Europe/Athens":180,"Europe/Belfast":60,"Europe/Belgrade":120,"Europe/Berlin":120,"Europe/Bratislava":120,"Europe/Brussels":120,"Europe/Bucharest":180,"Europe/Budapest":120,"Europe/Busingen":120,"Europe/Chisinau":180,"Europe/Copenhagen":120,"Europe/Dublin":60,"Europe/Gibraltar":120,"Europe/Guernsey":60,"Europe/Helsinki":180,"Europe/Isle_of_Man":60,"Europe/Istanbul":180,"Europe/Jersey":60,"Europe/Kaliningrad":120,"Europe/Kiev":180,"Europe/Lisbon":60,"Europe/Ljubljana":120,"Europe/London":60,"Europe/Luxembourg":120,"Europe/Madrid":120,"Europe/Malta":120,"Europe/Mariehamn":180,"Europe/Minsk":180,"Europe/Monaco":120,"Europe/Moscow":180,"Europe/Nicosia":180,"Europe/Oslo":120,"Europe/Paris":120,"Europe/Podgorica":120,"Europe/Prague":120,"Europe/Riga":180,"Europe/Rome":120,"Europe/Samara":240,"Europe/San_Marino":120,"Europe/Sarajevo":120,"Europe/Simferopol":180,"Europe/Skopje":120,"Europe/Sofia":180,"Europe/Stockholm":120,"Europe/Tallinn":180,"Europe/Tirane":120,"Europe/Tiraspol":180,"Europe/Uzhgorod":180,"Europe/Vaduz":120,"Europe/Vatican":120,"Europe/Vienna":120,"Europe/Vilnius":180,"Europe/Volgograd":180,"Europe/Warsaw":120,"Europe/Zagreb":120,"Europe/Zaporozhye":180,"Europe/Zurich":120,"Indian/Antananarivo":180,"Indian/Chagos":360,"Indian/Christmas":420,"Indian/Cocos":390,"Indian/Comoro":180,"Indian/Kerguelen":300,"Indian/Mahe":240,"Indian/Maldives":300,"Indian/Mauritius":240,"Indian/Mayotte":180,"Indian/Reunion":240,"Mexico/BajaNorte":-420,"Mexico/BajaSur":-360,"Mexico/General":-300,"Pacific/Apia":780,"Pacific/Auckland":720,"Pacific/Chatham":765,"Pacific/Chuuk":600,"Pacific/Easter":-300,"Pacific/Efate":660,"Pacific/Enderbury":780,"Pacific/Fakaofo":780,"Pacific/Fiji":720,"Pacific/Funafuti":720,"Pacific/Galapagos":-360,"Pacific/Gambier":-540,"Pacific/Guadalcanal":660,"Pacific/Guam":600,"Pacific/Honolulu":-600,"Pacific/Johnston":-600,"Pacific/Kiritimati":840,"Pacific/Kosrae":660,"Pacific/Kwajalein":720,"Pacific/Majuro":720,"Pacific/Marquesas":-570,"Pacific/Midway":-660,"Pacific/Nauru":720,"Pacific/Niue":-660,"Pacific/Norfolk":690,"Pacific/Noumea":660,"Pacific/Pago_Pago":-660,"Pacific/Palau":540,"Pacific/Pitcairn":-480,"Pacific/Pohnpei":660,"Pacific/Ponape":660,"Pacific/Port_Moresby":600,"Pacific/Rarotonga":-600,"Pacific/Saipan":600,"Pacific/Samoa":-660,"Pacific/Tahiti":-600,"Pacific/Tarawa":720,"Pacific/Tongatapu":780,"Pacific/Truk":600,"Pacific/Wake":720,"Pacific/Wallis":720,"Pacific/Yap":600} - - -# ############################################################### -# -# Functions -# -# ############################################################### - -def getTimeZoneList(): - "fill timezone list" - - Logger.debug('%s:' % whoami()) - - l = [k for k, v in sorted(timezones_json.iteritems(), key=lambda(k, v): (-v, k))] - #l = timezones_json.keys() - #Logger.debug('%s: %r' % (whoami(), l)) - - return l - -# ############################################################### - - -# ############################################################### -# -# Classes -# -# ############################################################### - -""" - dialog - select timezone in Settings -""" -class TzSettingDialog(SettingString): - tz = getTimeZoneList() - final_region = 'Europe' - final_city = 'Brussels' - - def _validate(self, instance): - """ validate and set result """ - self._dismiss() - self.value = "%s/%s" % (self.final_region, self.final_city) - Logger.debug('%s: %s' % (whoami(), self.value)) - - def redraw_citylist(self, region): - """ redraw city list """ - self.data_city = [] - for k in self.tz: - a = k.split('/') - if a[0] in region and a[1] not in self.data_city: - self.data_city.extend({a[1]}) - - self.data_city = sorted(self.data_city) - - self.list_adapter_city.data = self.data_city - - try: idc = self.data_city.index(self.final_city) - except: idc = -1 - - if idc >= 0: - self.list_adapter_city.get_view(idc).trigger_action(duration=0) - self.list_city.scroll_to(idc if idc < 5 else idc - 5) - else: - self.final_city = self.data_city[0] - """ - self.list_region._trigger_reset_populate() - if(hasattr(self.list_city, 'populate')): self.list_city.populate() - else: self.list_city._trigger_reset_populate() - """ - - def region_changed(self, adapter, **args): - """ new region has been selected """ - self.final_region = adapter.selection[0] if type(adapter.selection[0]) is str else adapter.selection[0].text - self.redraw_citylist(self.final_region) - - def city_changed(self, adapter, **args): - """ new city has been selected """ - if not len(adapter.selection): return - self.final_city = adapter.selection[0] if type(adapter.selection[0]) is str else adapter.selection[0].text - - def _create_popup(self, instance): - """ create popup layout """ - a = self.value.split('/') - self.final_region = a[0] - self.final_city = a[1] - - content = BoxLayout(orientation='vertical', spacing='5dp') - self.popup = popup = Popup(title=self.title, content=content, size_hint=(.69, .89)) - - ### content - start - region = [] - self.data_city = [] - for k in self.tz: - a = k.split('/') - if a[0] not in region: - region.extend({a[0]}) - - args_converter = lambda idx, rec: {'text': rec, - 'size_hint_y': None, - 'height': 32} - - self.list_adapter_city = ListAdapter(data=self.data_city, - args_converter=args_converter, - cls=ListItemButton, - selection_mode='single', - allow_empty_selection=False) - - self.list_city = ListView(adapter=self.list_adapter_city) - - region = sorted(region) - list_adapter_region = ListAdapter(data=region, - args_converter=args_converter, - cls=ListItemButton, - selection_mode='single', - allow_empty_selection=False) - list_adapter_region.bind(on_selection_change=self.region_changed) - - self.list_region = ListView(adapter=list_adapter_region, size_hint_x=.6) - - # construct the content, widget are used as a spacer - sellayout = BoxLayout(size_hint_y=1, spacing='5dp') - content.add_widget(sellayout) - sellayout.add_widget(self.list_region) - sellayout.add_widget(self.list_city) - - try: idr = region.index(self.final_region) - except: idr = 0 - list_adapter_region.get_view(idr).trigger_action(duration=0) - self.list_region.scroll_to(idr if idr < 5 else idr - 5) - self.list_adapter_city.bind(on_selection_change=self.city_changed) - ### content - end - -# content.add_widget(Widget()) - content.add_widget(SettingSpacer()) - - # 2 buttons are created for accept or cancel the current value - btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp') - btn = Button(text='Ok') - btn.bind(on_release=self._validate) - btnlayout.add_widget(btn) - btn = Button(text='Cancel') - btn.bind(on_release=self._dismiss) - btnlayout.add_widget(btn) - content.add_widget(btnlayout) - - # all done, open the popup ! - popup.open() - - -""" - customize Settings -""" -""" -class CustomSettings(Settings): - - def __init__(self, **kwargs): - super(CustomSettings, self).__init__(**kwargs) - - # register new item type - self.register_type('timezone', TzSettingDialog) -""" diff --git a/my_lib/tones.py b/my_lib/tones.py deleted file mode 100644 index a115e4a..0000000 --- a/my_lib/tones.py +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -from kivy.clock import Clock - -import os -import subprocess -import sys -import time - - -from kivy.logger import Logger - -from constants import * -from itools import * - - -############################################################### -# -# Declarations -# -# ############################################################### - -PHONERING_PLAYER = APLAYER + ' ' + APARAMS + RING_TONE - - -# ############################################################### -# -# Functions -# -# ############################################################### - -def ringingTones(): - "get list of ringing tones" - - Logger.debug('%s:' % whoami()) - - tones = [] - try: dirs = os.listdir('sounds/') - except: dirs = [] - - # This would print all the files and directories - for file in dirs: - if 'ring_' in file: - tones.append(file) - - return tones - - -# ############################################################################## - -def delCustomRingingTones(): - "delete customer's ringing tones" - - Logger.debug('%s:' % whoami()) - - try: dirs = os.listdir('sounds/') - except: dirs = [] - - # This would print all the files and directories - for file in dirs: - if 'ring_' in file: - try: os.remove('sounds/' + file) - except: pass - - -# ############################################################################## - -def playTone(tone): - "start play" - -# stopWAV() - - Logger.debug('%s: %s' %(whoami(), tone)) -### send_command(PHONERING_PLAYER) -## send_command(tone) - subprocess.Popen(tone.split()) - #Clock.schedule_once(lambda dt: subprocess.Popen(tone.split()), .5) -# Clock.schedule_once(lambda dt: send_command(tone)) - - -# ############################################################################## - -def playWAV(dt): - "start play ringing task" -# Logger.debug('%s: %s' %(whoami(), PHONERING_PLAYER)) -# subprocess.Popen(PHONERING_PLAYER.split()) - playTone(PHONERING_PLAYER) - - -# ############################################################################## - -def stopWAV(): - "stop play" - Logger.debug('%s: ' % whoami()) - send_command('pkill -9 ' + APLAYER) - - -# ############################################################################## diff --git a/my_lib/watches.py b/my_lib/watches.py deleted file mode 100644 index a4805b2..0000000 --- a/my_lib/watches.py +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -import kivy -kivy.require('1.9.0') - -from kivy.clock import Clock -from kivy.graphics import Color, Line, Rectangle, Ellipse -from kivy.uix.floatlayout import FloatLayout -from kivy.uix.label import Label -#from kivy.uix.screenmanager import Screen -from kivy.uix.widget import Widget - -from kivy.logger import Logger - -from math import cos, sin, pi - -import datetime - -from constants import * - - -############################################################### -# -# Declarations -# -# ############################################################### - -APP_LABEL = APP_NAME - - -# ############################################################### -# -# Classes -# -# ############################################################### - -class DigiClockWidget(FloatLayout): - "Clock class - digital" - pass - - -# ############################################################################## - -class DigiClock(Label): - "Label with date & time" - def __init__(self, **kwargs): - super(DigiClock, self).__init__(**kwargs) -# Clock.schedule_interval(self.update, 1) - self.starttimer() - - def update(self, *args): - t = datetime.datetime.now() - self.text = t.strftime("%H:%M:%S") - - def starttimer(self): - Clock.schedule_interval(self.update, 1) - - def stoptimer(self): - Clock.unschedule(self.update) - -# ############################################################################## - -class MyClockWidget(FloatLayout): - "Clock class - analog" - pass - - -# ############################################################################## - -class Ticks(Widget): - "Analog watches" - ln = Label() - - def __init__(self, **kwargs): - super(Ticks, self).__init__(**kwargs) - self.bind(pos = self.update_clock) - self.bind(size = self.update_clock) - - self.ln.pos = self.pos - self.ln.size = self.size - self.ln.font_size = '32sp' - self.ln.text_size = self.size - self.ln.halign = 'right' - self.ln.valign = 'bottom' - self.ln.markup = True - -# Clock.schedule_interval(self.update_clock, 1) - self.starttimer() - - - def starttimer(self): - Clock.schedule_interval(self.update_clock, 1) - - def stoptimer(self): - Clock.unschedule(self.update_clock) - - def update_clock(self, *args): - time = datetime.datetime.now() - self.canvas.clear() - - self.clear_widgets() -# self.ln.parent = None -# self.ln.pos = self.pos -# self.ln.size = self.size -# self.ln.text = '[color=0000f0] ' + APP_LABEL + ' [/color]' -# self.ln.text_size = self.size -# self.add_widget(self.ln) - - self.temps = 208 - self.postemp = [self.center_x - self.temps, self.center_y - self.temps] - self.sizetemp = [self.temps * 2, self.temps * 2] - -# Logger.debug('watch: w:%d h:%d x:%d y:%d cx:%d cy:%d' % (self.width, self.height, self.x, self.y, self.center_x, self.center_y)) - - with self.canvas: - Color(.2, .2, .2, .1) - Ellipse(pos=self.postemp, size=self.sizetemp) - - Color(.9, .9, .9) - Line(points = [self.center_x, self.center_y, self.center_x+0.7*self.r*sin(pi/30*time.second), - self.center_y+0.7*self.r*cos(pi/30*time.second)], width=1, cap="round") - Color(.7, .7, .7) - Line(points = [self.center_x, self.center_y, self.center_x+0.6*self.r*sin(pi/30*time.minute), - self.center_y+0.6*self.r*cos(pi/30*time.minute)], width=2, cap="round") - Color(.7, .7, .7) - th = time.hour * 60 + time.minute - Line(points = [self.center_x, self.center_y, self.center_x+0.5*self.r*sin(pi/360*th), - self.center_y+0.5*self.r*cos(pi/360*th)], width=3, cap="round") - - -# ############################################################################## diff --git a/my_lib/yesnodlg.py b/my_lib/yesnodlg.py deleted file mode 100644 index ebb2809..0000000 --- a/my_lib/yesnodlg.py +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/python - -# ############################################################### -# -# Imports -# -# ############################################################### - -import kivy -kivy.require('1.9.0') - - -from kivy.lang import Builder -from kivy.logger import Logger, LoggerHistory -from kivy.uix.boxlayout import BoxLayout -from kivy.uix.button import Button -from kivy.uix.image import Image -from kivy.uix.label import Label -from kivy.uix.popup import Popup -from kivy.uix.textinput import TextInput -from kivy.uix.widget import Widget - -from constants import * -from itools import * - - -# ############################################################### -# -# Popup Class - input text -# -# ############################################################### - -KV = ''' -BoxLayout: - orientation: 'vertical' - lbl1: lbl1 - btno: btno - btok: btok - spacing: 10 - - Label: - text: '' - id: lbl1 - - BoxLayout: - orientation: 'horizontal' - size_hint_y: None - height: 48 - spacing: 5 - - Button: - text: 'OK' - id: btok - Button: - text: 'Cancel' - id: btno -''' - - -class MyYesNoBox(Popup): - "Yes or no popup box" - def __init__(self, **kwargs): - super(MyYesNoBox, self).__init__(**kwargs) - - Logger.debug('%s: titl=$%s msg=%s' % (whoami(),kwargs.get('titl'),kwargs.get('txt'))) - - self.p = Builder.load_string(KV) - self.p.lbl1.text = kwargs.get('txt') or 'Are you sure?' - self.p.btok.bind(on_press=self.buttonOk) - self.p.btno.bind(on_press=self.buttonNo) - - self.title = kwargs.get('titl') or 'Confirm' - self.auto_dismiss = kwargs.get('ad') or False - self.cb = kwargs.get('cb') or None - self.size_hint = (.69, .6) - self.content = self.p - - - def buttonOk(self, b): - Logger.debug('%s: Yes' % (whoami())) - self.dismiss() - if not self.cb is None: self.cb() - - - def buttonNo(self, b): - Logger.debug('%s: No' % (whoami())) - self.dismiss() - - -# ##############################################################################