How to use set_target_command method in autotest

Best Python code snippet using autotest_python

service.py

Source:service.py Github

copy

Full Screen

...224 def list_command(service_name):225 return ["chkconfig", "--list"]226 return list_command227 elif command == "set_target":228 def set_target_command(target):229 target = convert_systemd_target_to_runlevel(target)230 return ["telinit", target]231 return set_target_command232 def method(service_name):233 return [command_name, service_name, command]234 return method235def systemd_command_generator(command):236 """237 Generate list of command line argument strings for systemctl.238 One argument per string for compatibility Popen239 WARNING: If systemctl detects that it is running on a tty it will use color,240 pipe to $PAGER, change column sizes and not truncate unit names.241 Use --no-pager to suppress pager output, or set PAGER=cat in the environment.242 You may need to take other steps to suppress color output.243 See https://bugzilla.redhat.com/show_bug.cgi?id=713567244 :param command: start,stop,restart, etc.245 :type command: str246 :return: list of command and arguments to pass to utils.run or similar functions247 :rtype: list248 """249 command_name = "systemctl"250 if command == "is_enabled":251 command = "is-enabled"252 elif command == "list":253 # noinspection PyUnusedLocal254 def list_command(service_name):255 # systemctl pipes to `less` or $PAGER by default. Workaround this256 # add '--full' to avoid systemctl truncates service names.257 return [command_name, "list-unit-files",258 "--type=service", "--no-pager", "--full"]259 return list_command260 elif command == "set_target":261 def set_target_command(target):262 return [command_name, "isolate", target]263 return set_target_command264 def method(service_name):265 return [command_name, command, "%s.service" % service_name]266 return method267COMMANDS = (268 "start",269 "stop",270 "reload",271 "restart",272 "condrestart",273 "status",274 "enable",275 "disable",...

Full Screen

Full Screen

maestro.py

Source:maestro.py Github

copy

Full Screen

1#!/usr/bin/env python2#################################################################3# Pololu Maestro USB Servo Controller4# By Jason De Lorme <jjdelorme@yahoo.com>5# 6import serial, time, struct, threading7from antprotocol.protocol import log8SET_TARGET_COMMAND=0x849GET_POSITION_COMMAND=0x9010GET_MOVING_STATE_COMMAND=0x9311# ----------------------------------------------------------------------------12#13# Class responsible for interacting with the Pololu Maestro controller.14#15# ----------------------------------------------------------------------------16class Maestro(serial.Serial):17 def __init__(self, port="/dev/ttyACM0", baudrate=9600, channel=0x05, timeout=1, debug=False):18 super(Maestro, self).__init__(port=port, baudrate=baudrate, timeout=timeout)19 self.channel = channel20 21 self._lock = threading.Lock()22 def __del__(self):23 self.close()24 def isMoving(self):25 try:26 # make sure it's not moving before you check the position.27 self.write( \28 chr(GET_MOVING_STATE_COMMAND))29 r = self.read(1)30 if r is not None:31 val = struct.unpack('?', r)32 return val[0]33 else:34 raise "ERROR Could not determine if servo was moving." 35 except Exception as e:36 print str(e)37 return False38 def getFastPosition(self, channel):39 try:40 self.write( \41 chr(GET_POSITION_COMMAND) + \42 chr(channel))43 r = self.read(2)44 if r is not None:45 pos = struct.unpack('h', r)46 else:47 return None48 49 return pos[0]50 except Exception as e:51 print "ERROR - getFastPosition: " + str(e)52 return 053 def getPosition(self):54 # let the servo finish moving if it is55 while self.isMoving():56 # wait just a 1/2 second and try again57 time.sleep(0.5)58 return self.getFastPosition(self.channel)59 def setTarget(self, position):60 low = position&0x7f61 high = position>>762 63 self.write( \64 chr(SET_TARGET_COMMAND) + \65 chr(self.channel) + \66 chr(low) + \67 chr(high))68 #69 # Threadsafe read implementation70 #71 def read(self, count):72 with self._lock:73 return super(Maestro, self).read(count)74 #75 # Threadsafe write implementation76 #77 def write(self, message):78 with self._lock:79 return super(Maestro, self).write(message)80# simple test harness to walk through the various steps.81def _test(port="/dev/ttyACM0", channel=0x05):82 m = Maestro(port=port, channel=channel)83 m.setTarget(8428) # 0 resistance84 time.sleep(1.0)85 m.setTarget(5090) # 1 resistance86 time.sleep(1.0)87 m.setTarget(4600) # 2 resistance88 time.sleep(1.0)89 m.setTarget(2796) # 3 resistance90 time.sleep(2.0)91 m.setTarget(8428)...

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 autotest 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