How to use get_carrier method in autotest

Best Python code snippet using autotest_python

statistics.py

Source:statistics.py Github

copy

Full Screen

...12from functools import wraps13import numpy as np14import pandas as pd15from pypsa.descriptors import nominal_attrs16def get_carrier(n, c):17 """18 Get the nice carrier names for a component.19 """20 df = n.df(c)21 fall_back = pd.Series("", index=df.index)22 return (23 df.get("carrier", fall_back)24 .replace(n.carriers.nice_name[lambda ds: ds != ""])25 .replace("", "-")26 .rename("carrier")27 )28def get_bus_and_carrier(n, c):29 """30 Get the buses and nice carrier names for a component.31 """32 if "bus" not in n.df(c):33 bus = "bus0"34 else:35 bus = "bus"36 return [n.df(c)[bus].rename("bus"), get_carrier(n, c)]37def get_operation(n, c):38 """39 Get the operation time series of a component.40 """41 if c in n.branch_components:42 return n.pnl(c).p043 elif c == "Store":44 return n.pnl(c).e45 else:46 return n.pnl(c).p47def get_weightings(n, c):48 """49 Get the relevant snapshot weighting for a component.50 """...

Full Screen

Full Screen

network_SwitchCarrier.py

Source:network_SwitchCarrier.py Github

copy

Full Screen

...12 self.loop.quit()13 def device_added(self, dev, *args, **kwargs):14 print 'Device added: %s' % dev15 self.modem = self.bus.get_object(self.CMM, dev)16 carrier = self.get_carrier()17 if not carrier:18 print 'No carrier.'19 return20 if carrier != self.to_carrier:21 self.fail('Wrong carrier: %s != %s' % (carrier, self.to_carrier))22 if not self.carriers:23 self.loop.quit() # success!24 return25 while len(self.carriers):26 try:27 self.to_carrier = self.carriers[0]28 self.carriers = self.carriers[1:]29 self.set_carrier(self.to_carrier)30 break31 except dbus.exceptions.DBusException, e:32 if e.get_dbus_message() == "Unknown carrier name":33 print 'Ignoring invalid carrier %s' % self.to_carrier34 continue35 raise36 def device_removed(self, *args, **kwargs):37 print 'Device removed.'38 def waitfor(self, signame, fn):39 print 'Waiting for %s' % signame40 self.bus.add_signal_receiver(fn, signal_name=signame,41 dbus_interface=self.IMM)42 def timeout(self):43 self.fail('Timeout')44 def get_carrier(self):45 status = self.modem.GetStatus(dbus_interface=self.IMODEM_SIMPLE)46 if not status or not 'carrier' in status:47 self.fail('Bogus GetStatus reply: %s' % status)48 return None49 return status['carrier']50 def set_carrier(self, c):51 print 'Switch: ? -> %s' % c52 self.modem.SetCarrier(c, dbus_interface=self.IMODEM_GOBI)53 def find_modem(self):54 modems = self.mm.EnumerateDevices(dbus_interface=self.IMM)55 if modems:56 self.modem = self.bus.get_object(self.CMM, modems[0])57 else:58 self.modem = None59 def run_once(self, start_carrier='Verizon Wireless',60 carriers=None,61 timeout_secs=90):62 carriers = carriers or ['Vodafone', 'Sprint', 'Verizon Wireless']63 self.CMM = 'org.chromium.ModemManager'64 self.IMM = 'org.freedesktop.ModemManager'65 self.IMODEM_SIMPLE = self.IMM + '.Modem.Simple'66 self.IMODEM_GOBI = 'org.chromium.ModemManager.Modem.Gobi'67 self.failed = None68 self.carriers = carriers69 self.to_carrier = None70 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)71 self.loop = gobject.MainLoop()72 self.bus = dbus.SystemBus()73 gobject.timeout_add(timeout_secs * 1000, self.timeout)74 self.mm = self.bus.get_object(self.CMM, '/org/chromium/ModemManager')75 self.find_modem()76 self.waitfor('DeviceRemoved', self.device_removed)77 self.waitfor('DeviceAdded', self.device_added)78 carrier = self.get_carrier()79 if not carrier:80 raise self.failed81 self.to_carrier = carrier82 self.device_added(self.modem.__dbus_object_path__) # start test83 self.loop.run()84 self.find_modem()85 if self.modem and self.to_carrier != carrier:86 self.set_carrier(carrier)87 if self.failed:...

Full Screen

Full Screen

carriers.py

Source:carriers.py Github

copy

Full Screen

2import mkt.constants.carriers3from mkt.constants.carriers import CARRIERS4__all__ = ['get_carrier', 'get_carrier_id', 'set_carrier']5_local = local()6def get_carrier():7 """8 Returns the name of the current carrier (or None) for the9 request lifecycle.10 Example: telefonica11 """12 return getattr(_local, 'carrier', None)13def get_carrier_id():14 """Returns the carrier ID for the request lifecycle."""15 carrier = get_carrier()16 if carrier is None:17 return carrier18 for carr in CARRIERS:19 if carr.slug == carrier:20 return carr.id21 return mkt.constants.carriers.UNKNOWN_CARRIER.id22def set_carrier(name):23 """24 Sets the name of the carrier for the current request lifecycle.25 """26 _local.carrier = name27class CarrierPrefixer:28 def __init__(self, request, carrier):29 self.request = request...

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