How to use restart_device method in lisa

Best Python code snippet using lisa_python

test.py

Source:test.py Github

copy

Full Screen

...71 if wait > 0:72 time.sleep(10)73 ret = wait_for_device(udid, apsthome, wait)74 print(f'restart_per_device_3: -- [{udid}]: return={ret}')75def restart_device(devices, apsthome):76 print('restart_device: ++')77 tasks = []78 for dev in devices:79 # restart_per_device(dev, apsthome)80 t = threading.Thread(target=restart_per_device_1, args=(dev, apsthome,), daemon=True)81 # t = threading.Thread(target=restart_per_device_2, args=(dev, apsthome,), daemon=True)82 t.start()83 tasks.append(t)84 print('restart_device: wait for all tasks complete.')85 for t in tasks:86 t.join()87 print('restart_device: --')88def get_device_info(apsthome, udid):89 info = {}90 wd = os.path.join(apsthome, 'phonedll', 'PST_APE_UNIVERSAL_USB_FD', 'resource')91 fn = os.path.join(wd, 'iDeviceUtilCore.exe')92 cmd = [fn, '--udid', udid, '--info']93 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, cwd=wd)94 p.wait()95 s = p.communicate()96 lines = s[0].decode().split('\r\n')97 for l in lines:98 pos = l.find('=')99 if pos>0:100 k = l[:pos]101 v = l[pos+1:]102 info[k] = v103 return info104apsthome = os.getenv('apsthome', r'C:\\ProgramData\\Futuredial\\CMC')105devs = listiPhone(apsthome)106print(f'There are {len(devs)} devices found.')107print(devs)108# restart_device([devs[0]], apsthome)109restart_device(devs, apsthome)110# info = get_device_info(apsthome, devs[0])...

Full Screen

Full Screen

device_release.py

Source:device_release.py Github

copy

Full Screen

1from django.http import HttpRequest, JsonResponse2from devices.model_dir.Devices import Device3from devices.model_dir.DeviceFunction import DeviceFunction4from devices.views_dir.common.logging import log_request5from devices.common.functions import safe_get_model_by, safe_set_model_values6import logging7log = logging.getLogger('adms.views')8def get(request: HttpRequest, **kwargs):9 log.info(log_request(request, ""))10 device_key = kwargs.get('device_key')11 try:12 device: Device = safe_get_model_by(Device, pk=device_key)13 except Device.DoesNotExist:14 # TODO extract function and make all endpoints that return this use it15 log.warning(log_request(request, "Failed to find device: '%s'" % device_key))16 return JsonResponse({'Error': "Device '%s' does not exist" % device_key}, status=404)17 request_host_ip = request.META['REMOTE_ADDR']18 if device.owner != request_host_ip:19 log.warning(log_request(request, "Device being released by a host which is not the owner!\n "20 "Owner was: '%s' Released by: '%s'" % (device.owner, request_host_ip)))21 safe_set_model_values(Device, device_key, allocated=False, owner=None)22 log.info(log_request(request, "Released device: '%s'" % device_key))23 # TODO restarting the device should go here24 try:25 restart_device: DeviceFunction = safe_get_model_by(DeviceFunction, key="%s-%s" % (device.type, 'restart'))26 if restart_device.exists():27 tpe = kwargs.get('the_tpe')28 tpe.submit(restart_device.execute_function, device_key)29 # restart_device.execute_function(device)30 # if int(restart_device.exit_code) != 0 and int(restart_device.exit_code) != 2:31 # log.warning("Device Function with unexpected exit code:\n\t%s\n\t%s\n\t%s" %32 # (restart_device.stdout, restart_device.stderr, restart_device.exit_code))33 except DeviceFunction.DoesNotExist:34 # TODO add log output because somebody needs to know that what they are calling doesnt exist35 log.warning("Function '%s-%s' was called but does not exist" % (device.type, 'restart'))...

Full Screen

Full Screen

urls.py

Source:urls.py Github

copy

Full Screen

1"""admin_untect URL Configuration2The `urlpatterns` list routes URLs to views. For more information please see:3 https://docs.djangoproject.com/en/3.2/topics/http/urls/4Examples:5Function views6 1. Add an import: from my_app import views7 2. Add a URL to urlpatterns: path('', views.home, name='home')8Class-based views9 1. Add an import: from other_app.views import Home10 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')11Including another URLconf12 1. Import the include() function: from django.urls import include, path13 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))14"""15from django.contrib import admin16from django.urls import path17from app.views import restart_device,device_info,device_jupyter18urlpatterns = [19 path('admin/', admin.site.urls),20 path('restart_device',restart_device),21 path('device_jupyter',device_jupyter),22 path('device_info',device_info)23 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful