Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from kivy.lang import Builder
from main import get_plugins_list, create_folder
import main_utils
from main_utils import current_activity
from . import MobileInsightScreenBase
import traceback
Builder.load_file('screens/home.kv')
LOGO_STRING = "MobileInsight " + main_utils.get_cur_version() + \
"\nCopyright (c) 2015-2017 MobileInsight Team"
class HomeScreen(MobileInsightScreenBase):
error_log = StringProperty(LOGO_STRING)
default_app_name = StringProperty("")
collecting = BooleanProperty(False)
service = None
analyzer = None
terminal_thread = None
terminal_stop = None
MAX_LINE = 30
logs = deque([], MAX_LINE)
plugins = []
selectedPlugin = ""
app_list = get_plugins_list()
myLayout = GridLayout(cols=2, spacing=5,
orientation="vertical", size_hint_y=None,
height=(len(app_list) / 2 + len(app_list) % 2) * Window.height / 4)
popupScroll = ScrollView(size_hint_y=None, size=(Window.width, Window.height*.9))
popupScroll.add_widget(myLayout)
popup = Popup(content=popupScroll, title="Choose a plugin")
attach_to = ObjectProperty(allownone=True)
'''(internal) Property that will be set to the widget on which the
drop down list is attached to.
The method :meth:`open` will automatically set that property, while
:meth:`dismiss` will set back to None.
'''
auto_width = BooleanProperty(True)
'''By default, the width of the ContextMenu will be the same
as the width of the attached widget. Set to False if you want
to provide your own width.
'''
dismiss_on_select = BooleanProperty(True)
'''By default, the ContextMenu will be automatically dismissed
when a selection have been done. Set to False to prevent the dismiss.
:data:`dismiss_on_select` is a :class:`~kivy.properties.BooleanProperty`,
default to True.
'''
max_height = NumericProperty(None, allownone=True)
'''Indicate the maximum height that the dropdown can take. If None, it will
take the maximum height available, until the top or bottom of the screen
will be reached.
:data:`max_height` is a :class:`~kivy.properties.NumericProperty`, default
to None.
'''
'''Defines the duration of the Carousel animation between pages.
:attr:`anim_move_duration` is a :class:`~kivy.properties.NumericProperty`
and defaults to 0.5.
'''
anim_cancel_duration = NumericProperty(0.3)
'''Defines the duration of the animation when a swipe movement is not
accepted. This is generally when the user does not make a large enough
swipe. See :attr:`min_move`.
:attr:`anim_cancel_duration` is a :class:`~kivy.properties.NumericProperty`
and defaults to 0.3.
'''
loop = BooleanProperty(False)
'''Allow the Carousel to loop infinitely. If True, when the user tries to
swipe beyond last page, it will return to the first. If False, it will
remain on the last page.
:attr:`loop` is a :class:`~kivy.properties.BooleanProperty` and
defaults to False.
'''
def _get_index(self):
if self.slides:
return self._index % len(self.slides)
return None
def _set_index(self, value):
if self.slides:
self._index = value % len(self.slides)
#if os.name == "nt":
#Window.size = (600,900)
#else:
# Window.size = (700,900)
Width = list(Window.size)[0]
JsonData = DictProperty()
debug = True
version = StringProperty(__version__)
JsonSTR = StringProperty()
camconfig = DictProperty()
token = NumericProperty(0)
Jsoncounter = NumericProperty(0)
Jsonflip = NumericProperty(0)
connected = BooleanProperty()
started = BooleanProperty()
readcfg = BooleanProperty()
#btnConnect = "Connect to XiaoYi"
#srv = ObjectProperty()
lock = False
def Debug(self):
if self.debug:
self.ids.btnDebug.color=(1,1,1,1)
self.ids.txtDebug.foreground_color=(1,1,1,1)
if len(self.ids.txtDebug.text)>0:
self.ids.txtDebug.text = ""
def ShowDebug(self, str):
if self.debug:
if str != "":
self.ids.txtDebug.text += "\n%s" %str
ripple_rad = NumericProperty()
ripple_rad_default = NumericProperty(1)
ripple_post = ListProperty()
ripple_color = ListProperty()
ripple_alpha = NumericProperty(.5)
ripple_scale = NumericProperty(None)
ripple_duration_in_fast = NumericProperty(.3)
# FIXME: These speeds should be calculated based on widget size in dp
ripple_duration_in_slow = NumericProperty(2)
ripple_duration_out = NumericProperty(.3)
ripple_func_in = StringProperty('out_quad')
ripple_func_out = StringProperty('out_quad')
doing_ripple = BooleanProperty(False)
finishing_ripple = BooleanProperty(False)
fading_out = BooleanProperty(False)
def on_touch_down(self, touch):
if touch.is_mouse_scrolling:
return False
if not self.collide_point(touch.x, touch.y):
return False
if not self.disabled:
if self.doing_ripple:
Animation.cancel_all(self, 'ripple_rad', 'ripple_color',
'rect_color')
self.anim_complete()
self.ripple_rad = self.ripple_rad_default
self.ripple_pos = (touch.x, touch.y)
if self.ripple_color != []:
sprint_count = NumericProperty(0)
time_display = StringProperty()
time_minute = StringProperty()
time_second = StringProperty()
state = StringProperty()
start = StringProperty()
stop = StringProperty()
logs = ListProperty([])
server_url = StringProperty()
#"http://172.18.140.79:8000/api/v1.0/put/pomodoro"
server_user = StringProperty("barbaros")
server_send = BooleanProperty(False)
count_start = BooleanProperty(False)
connect_server = BooleanProperty(False)
buttons = ListProperty()
def __init__(self, *args, **kwargs):
super(Pomodoro, self).__init__(*args, **kwargs)
self.buttons = get_buttons(self, [])
self.animation = None
self.clock = SoundLoader.load('assets/clock.wav')
self.alarm = SoundLoader.load('assets/alarm.wav')
self.load_log_dates()
#self.load_logs()
try:
last_session = DB.store_get('last_session')
except KeyError:
radius = NumericProperty(0)
class ColouredToggleButton(ToggleButtonBehavior, Label):
background_normal = ListProperty([1, 1, 1, 1])
background_down = ListProperty([0.5, 0.5, 0.5, 1])
padding = NumericProperty(0)
radius = NumericProperty(0)
class ColouredButtonContainer(ButtonBehavior, AnchorLayout):
background_normal = ListProperty([1, 1, 1, 1])
background_down = ListProperty([0.5, 0.5, 0.5, 1])
coloured_button_padding = NumericProperty(0)
radius = NumericProperty(0)
class ButtonCheckbox(ButtonBehavior, Label):
active = BooleanProperty(True)
box_size = NumericProperty()
draw_colour = ListProperty((0.2, 0.2, 0.2, 1))
text_colour = ListProperty((0.0, 0.0, 0.0, 1))
handle_touch = BooleanProperty(True)
def on_touch_down(self, touch):
if not self.handle_touch:
return False
return super(ButtonCheckbox, self).on_touch_down(touch)
#print "Clock.max_iteration", Clock.max_iteration
Clock.max_iteration = 100
__version__='0.0.7'
class MConnectScreen(Screen):
pass
class AdvancedPopup(Popup):
scenename = StringProperty()
scenecount = NumericProperty()
autorename = BooleanProperty()
moveduplicated = BooleanProperty()
buzzeronstart = BooleanProperty()
buzzeronstop = BooleanProperty()
buzzermute = BooleanProperty()
loadallsettings = BooleanProperty()
photomode = BooleanProperty()
apply = BooleanProperty()
class ConfigPopup(Popup):
cfg = ObjectProperty()
apply = BooleanProperty()
class CameraSettingPopup(Popup):
asid = StringProperty()
format = BooleanProperty()
restore = BooleanProperty()
syncall = BooleanProperty()
apply = BooleanProperty()
class ManualExposurePopup(Popup):
shutter = StringProperty()
defaults to ''
'''
kv_path = StringProperty('')
'''RootWidget associated kv file path.
:data:`kv_path` is a :class:`~kivy.properties.StringProperty` and
default to ''
'''
py_path = StringProperty('')
'''RootWidget associated py file path.
:data:`py_path` is a :class:`~kivy.properties.StringProperty` and
default to ''
'''
is_root = BooleanProperty(False)
'''Indicates if this widget is a root/default kivy widget or not
:data:`is_root` is a :class:`~kivy.properties.BooleanProperty` and
defaults to False
'''
instance = ObjectProperty(None)
'''If the widget is root, it has a instance returned by Builder.load_string
If not is root, instance is None
data:`instance` is a :class:`~kivy.properties.ObjectProperty` and
defaults to None
'''
is_dynamic = BooleanProperty(False)
'''Indicates if this widget is a dynamic widget or not
:data:`is_dynamic` is a :class:`~kivy.properties.BooleanProperty` and
defaults to False