How to use _resource method in localstack

Best Python code snippet using localstack_python

uwschelp.py

Source:uwschelp.py Github

copy

Full Screen

1# coding: utf-82import os3import subprocess4import sublime5import sublime_plugin6class UwscHelpCommand(sublime_plugin.TextCommand):7 def run(self, edit):8 point = self.view.sel()[0].begin()9 if self.view.scope_name(point).find('source.uwsc') == -1:10 return11 word_on_point = self.view.word(point)12 word = self.view.substr(word_on_point)13 def output(text):14 window = self.view.window()15 output_view = window.get_output_panel("textarea")16 window.run_command("show_panel", {"panel": "output.textarea"})17 output_view.set_read_only(False)18 if int(sublime.version()) < 3000:19 _edit = output_view.begin_edit()20 output_view.insert(_edit, output_view.size(), text)21 output_view.end_edit(_edit)22 else:23 output_view.insert(edit, output_view.size(), text)24 output_view.set_read_only(True)25 uwsc_path = self.view.settings().get('uwsc_path')26 if uwsc_path.__class__.__name__ == 'list':27 for p in uwsc_path:28 help_path = os.path.join(p, 'uwsc.chm')29 if os.path.exists(help_path):30 break31 else:32 err = u'uwsc.chm が見つかりませんでした\nuwsc_pathの設定を確認して下さい'33 output(err)34 return35 else:36 help_path = os.path.join(uwsc_path, 'uwsc.chm')37 if not os.path.exists(help_path):38 err = u'{0} が開けませんでした\nuwsc_pathの設定を確認して下さい'.format(help_path)39 output(err)40 return41 if word.upper() in self.keywords:42 url = self.keywords[word.upper()]43 args = '{0} {1}'.format(help_path, url)44 subprocess.Popen(['hh.exe', args], shell=False)45 else:46 args = '{0}'.format(help_path)47 subprocess.Popen(['hh.exe', args], shell=False)48 # For UWSC version 5.1249 keywords = {50 'ACW': '::/_RESOURCE/function.htm#acw',51 'ASC': '::/_RESOURCE/function.htm#asc',52 'BETWEENSTR': '::/_RESOURCE/function.htm#betweenstr',53 'BREAK': '::/_RESOURCE/syntax.htm#break',54 'BTN': '::/_RESOURCE/function.htm#btn',55 'CALCARRAY': '::/_RESOURCE/function.htm#calcarray',56 'CALL': '::/_RESOURCE/syntax.htm#call',57 'CHGMOJ': '::/_RESOURCE/function.htm#chgmoj',58 'CHKBTN': '::/_RESOURCE/function.htm#chkbtn',59 'CHKIMG': '::/_RESOURCE/function.htm#chkimg',60 'CHKNUM': '::/_RESOURCE/function.htm#chknum',61 'CHR': '::/_RESOURCE/function.htm#chr',62 'CLASS': '::/_RESOURCE/syntax.htm#class',63 'CLKITEM': '::/_RESOURCE/function.htm#clkitem',64 'COM_ERR_IGN': '::/_RESOURCE/function.htm#com_err_ign',65 'COMMENT': '::/_RESOURCE/syntax.htm#comment',66 'CONSTANT': '::/_RESOURCE/syntax.htm#constant',67 'CONSTDEF': '::/_RESOURCE/syntax.htm#constdef',68 'CONTINUE': '::/_RESOURCE/syntax.htm#continue',69 'COPY': '::/_RESOURCE/function.htm#copy',70 'CPUUSERATE': '::/_RESOURCE/function.htm#cpuuserate',71 'CREATEFORM': '::/_RESOURCE/function.htm#createform',72 'CREATEOLEOBJ': '::/_RESOURCE/function.htm#createoleobj',73 'CTRLWIN': '::/_RESOURCE/function.htm#ctrlwin',74 'DECODE': '::/_RESOURCE/function.htm#decode',75 'DEF_DLL': '::/_RESOURCE/syntax.htm#def_dll',76 'DELETEFILE': '::/_RESOURCE/function.htm#deletefile',77 'DELETEINI': '::/_RESOURCE/function.htm#deleteini',78 'DICTATE': '::/_RESOURCE/function.htm#dictate',79 'DOSCMD': '::/_RESOURCE/function.htm#doscmd',80 'DROPFILE': '::/_RESOURCE/function.htm#dropfile',81 'ENCODE': '::/_RESOURCE/function.htm#encode',82 'EVAL': '::/_RESOURCE/function.htm#eval',83 'EXCEL': '::/_RESOURCE/function.htm#excel',84 'EXCEPTION': '::/_RESOURCE/syntax.htm#exception',85 'EXEC': '::/_RESOURCE/function.htm#exec',86 'EXIT': '::/_RESOURCE/syntax.htm#exit',87 'FCLOSE': '::/_RESOURCE/function.htm#fclose',88 'FDELLINE': '::/_RESOURCE/function.htm#fdelline',89 'FGET': '::/_RESOURCE/function.htm#fget',90 'FOPEN': '::/_RESOURCE/function.htm#fopen',91 'FORM': '::/_RESOURCE/function.htm#form',92 'FORMAT': '::/_RESOURCE/function.htm#format',93 'FPUT': '::/_RESOURCE/function.htm#fput',94 'FUKIDASI': '::/_RESOURCE/function.htm#fukidasi',95 'FUNCTION': '::/_RESOURCE/syntax.htm#function',96 'GETACTIVEOLEOBJ': '::/_RESOURCE/function.htm#getactiveoleobj',97 'GETALLWIN': '::/_RESOURCE/function.htm#getallwin',98 'GETCTLHND': '::/_RESOURCE/function.htm#getctlhnd',99 'GETDIR': '::/_RESOURCE/function.htm#getdir',100 'GETFORMDATA': '::/_RESOURCE/function.htm#getformdata',101 'GETID': '::/_RESOURCE/function.htm#getid',102 'GETITEM': '::/_RESOURCE/function.htm#getitem',103 'GETKEYSTATE': '::/_RESOURCE/function.htm#getkeystate',104 'GETOLEITEM': '::/_RESOURCE/function.htm#getoleitem',105 'GETSLCTLST': '::/_RESOURCE/function.htm#getslctlst',106 'GETSLIDER': '::/_RESOURCE/function.htm#getslider',107 'GETSTR': '::/_RESOURCE/function.htm#getstr',108 'GETTIME': '::/_RESOURCE/function.htm#gettime',109 'HASHTABLE': '::/_RESOURCE/syntax.htm#hashtable',110 'HEXADECIMAL': '::/_RESOURCE/syntax.htm#hexadecimal',111 'IDTOHND': '::/_RESOURCE/function.htm#idtohnd',112 'IEGETDATA': '::/_RESOURCE/function.htm#iegetdata',113 'IEGETSRC': '::/_RESOURCE/function.htm#iegetsrc',114 'IELINK': '::/_RESOURCE/function.htm#ielink',115 'IEOPERATION': '::/_RESOURCE/function.htm#ieoperation',116 'IESETDATA': '::/_RESOURCE/function.htm#iesetdata',117 'IESETSRC': '::/_RESOURCE/function.htm#iesetsrc',118 'IF': '::/_RESOURCE/syntax.htm#if',119 'IFB': '::/_RESOURCE/syntax.htm#ifb',120 'INIFILE': '::/_RESOURCE/function.htm#inifile',121 'INPUT': '::/_RESOURCE/function.htm#input',122 'ISUNICODE': '::/_RESOURCE/function.htm#isunicode',123 'JOIN': '::/_RESOURCE/function.htm#join',124 'KBD': '::/_RESOURCE/function.htm#kbd',125 'KINDOFOS': '::/_RESOURCE/function.htm#kindofos',126 'LENGTH': '::/_RESOURCE/function.htm#length',127 'LOCKHARD': '::/_RESOURCE/function.htm#lockhard',128 'LOCKHARDEX': '::/_RESOURCE/function.htm#lockhardex',129 'MATHFUNC': '::/_RESOURCE/function.htm#mathfunc',130 'MMV': '::/_RESOURCE/function.htm#mmv',131 'MONITOR': '::/_RESOURCE/function.htm#monitor',132 'MOUSEORG': '::/_RESOURCE/function.htm#mouseorg',133 'MSGBOX': '::/_RESOURCE/function.htm#msgbox',134 'MUSCUR': '::/_RESOURCE/function.htm#muscur',135 'OLEEVENT': '::/_RESOURCE/function.htm#oleevent',136 'OPTION': '::/_RESOURCE/syntax.htm#option',137 'PEEKCOLOR': '::/_RESOURCE/function.htm#peekcolor',138 'POFF': '::/_RESOURCE/function.htm#poff',139 'POPUPMENU': '::/_RESOURCE/function.htm#popupmenu',140 'POS': '::/_RESOURCE/function.htm#pos',141 'POSACC': '::/_RESOURCE/function.htm#posacc',142 'POWERSHELL': '::/_RESOURCE/function.htm#powershell',143 'PRINT': '::/_RESOURCE/syntax.htm#print',144 'PROCEDURE': '::/_RESOURCE/syntax.htm#procedure',145 'QSORT': '::/_RESOURCE/function.htm#qsort',146 'READINI': '::/_RESOURCE/function.htm#readini',147 'RECOSTATE': '::/_RESOURCE/function.htm#recostate',148 'RESIZE': '::/_RESOURCE/function.htm#resize',149 'SAFEARRAY': '::/_RESOURCE/function.htm#safearray',150 'SAVEIMG': '::/_RESOURCE/function.htm#saveimg',151 'SCKEY': '::/_RESOURCE/function.htm#sckey',152 'SENDSTR': '::/_RESOURCE/function.htm#sendstr',153 'SENSOR': '::/_RESOURCE/function.htm#sensor',154 'SETCLEAR': '::/_RESOURCE/function.htm#setclear',155 'SETFORMDATA': '::/_RESOURCE/function.htm#setformdata',156 'SETHOTKEY': '::/_RESOURCE/function.htm#sethotkey',157 'SETSLIDER': '::/_RESOURCE/function.htm#setslider',158 'SHIFTARRAY': '::/_RESOURCE/function.htm#shiftarray',159 'SLCTBOX': '::/_RESOURCE/function.htm#slctbox',160 'SLEEP': '::/_RESOURCE/function.htm#sleep',161 'SLICE': '::/_RESOURCE/function.htm#slice',162 'SOUND': '::/_RESOURCE/function.htm#sound',163 'SPEAK': '::/_RESOURCE/function.htm#speak',164 'SPLIT': '::/_RESOURCE/function.htm#split',165 'STATUS': '::/_RESOURCE/function.htm#status',166 'STOPFORM': '::/_RESOURCE/function.htm#stopform',167 'STRCONV': '::/_RESOURCE/function.htm#strconv',168 'STRINGS': '::/_RESOURCE/syntax.htm#strings',169 'TEXTBLOCK': '::/_RESOURCE/syntax.htm#textblock',170 'THREAD': '::/_RESOURCE/syntax.htm#thread',171 'TOKEN': '::/_RESOURCE/function.htm#token',172 'TRIM': '::/_RESOURCE/function.htm#trim',173 'VAL': '::/_RESOURCE/function.htm#val',174 'VARIABLE': '::/_RESOURCE/syntax.htm#variable',175 'VARTYPE': '::/_RESOURCE/function.htm#vartype',176 'VOICERECOGNITION': '::/_RESOURCE/function.htm#voicerecognition',177 'WITH': '::/_RESOURCE/syntax.htm#with',178 'WRITEINI': '::/_RESOURCE/function.htm#writeini',179 'XLACTIVATE': '::/_RESOURCE/function.htm#xlactivate',180 'XLCLOSE': '::/_RESOURCE/function.htm#xlclose',181 'XLGETDATA': '::/_RESOURCE/function.htm#xlgetdata',182 'XLOPEN': '::/_RESOURCE/function.htm#xlopen',183 'XLSETDATA': '::/_RESOURCE/function.htm#xlsetdata',184 'XLSHEET': '::/_RESOURCE/function.htm#xlsheet',...

Full Screen

Full Screen

switch.py

Source:switch.py Github

copy

Full Screen

1"""Support for an exposed aREST RESTful API of a device."""2import logging3import requests4import voluptuous as vol5from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA)6from homeassistant.const import (CONF_NAME, CONF_RESOURCE)7import homeassistant.helpers.config_validation as cv8_LOGGER = logging.getLogger(__name__)9CONF_FUNCTIONS = 'functions'10CONF_PINS = 'pins'11CONF_INVERT = 'invert'12DEFAULT_NAME = 'aREST switch'13PIN_FUNCTION_SCHEMA = vol.Schema({14 vol.Optional(CONF_NAME): cv.string,15 vol.Optional(CONF_INVERT, default=False): cv.boolean,16})17PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({18 vol.Required(CONF_RESOURCE): cv.url,19 vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,20 vol.Optional(CONF_PINS, default={}):21 vol.Schema({cv.string: PIN_FUNCTION_SCHEMA}),22 vol.Optional(CONF_FUNCTIONS, default={}):23 vol.Schema({cv.string: PIN_FUNCTION_SCHEMA}),24})25def setup_platform(hass, config, add_entities, discovery_info=None):26 """Set up the aREST switches."""27 resource = config.get(CONF_RESOURCE)28 try:29 response = requests.get(resource, timeout=10)30 except requests.exceptions.MissingSchema:31 _LOGGER.error("Missing resource or schema in configuration. "32 "Add http:// to your URL")33 return False34 except requests.exceptions.ConnectionError:35 _LOGGER.error("No route to device at %s", resource)36 return False37 dev = []38 pins = config.get(CONF_PINS)39 for pinnum, pin in pins.items():40 dev.append(ArestSwitchPin(41 resource, config.get(CONF_NAME, response.json()[CONF_NAME]),42 pin.get(CONF_NAME), pinnum, pin.get(CONF_INVERT)))43 functions = config.get(CONF_FUNCTIONS)44 for funcname, func in functions.items():45 dev.append(ArestSwitchFunction(46 resource, config.get(CONF_NAME, response.json()[CONF_NAME]),47 func.get(CONF_NAME), funcname))48 add_entities(dev)49class ArestSwitchBase(SwitchDevice):50 """Representation of an aREST switch."""51 def __init__(self, resource, location, name):52 """Initialize the switch."""53 self._resource = resource54 self._name = '{} {}'.format(location.title(), name.title())55 self._state = None56 self._available = True57 @property58 def name(self):59 """Return the name of the switch."""60 return self._name61 @property62 def is_on(self):63 """Return true if device is on."""64 return self._state65 @property66 def available(self):67 """Could the device be accessed during the last update call."""68 return self._available69class ArestSwitchFunction(ArestSwitchBase):70 """Representation of an aREST switch."""71 def __init__(self, resource, location, name, func):72 """Initialize the switch."""73 super().__init__(resource, location, name)74 self._func = func75 request = requests.get(76 '{}/{}'.format(self._resource, self._func), timeout=10)77 if request.status_code != 200:78 _LOGGER.error("Can't find function")79 return80 try:81 request.json()['return_value']82 except KeyError:83 _LOGGER.error("No return_value received")84 except ValueError:85 _LOGGER.error("Response invalid")86 def turn_on(self, **kwargs):87 """Turn the device on."""88 request = requests.get(89 '{}/{}'.format(self._resource, self._func), timeout=10,90 params={'params': '1'})91 if request.status_code == 200:92 self._state = True93 else:94 _LOGGER.error(95 "Can't turn on function %s at %s", self._func, self._resource)96 def turn_off(self, **kwargs):97 """Turn the device off."""98 request = requests.get(99 '{}/{}'.format(self._resource, self._func), timeout=10,100 params={'params': '0'})101 if request.status_code == 200:102 self._state = False103 else:104 _LOGGER.error(105 "Can't turn off function %s at %s", self._func, self._resource)106 def update(self):107 """Get the latest data from aREST API and update the state."""108 try:109 request = requests.get(110 '{}/{}'.format(self._resource, self._func), timeout=10)111 self._state = request.json()['return_value'] != 0112 self._available = True113 except requests.exceptions.ConnectionError:114 _LOGGER.warning("No route to device %s", self._resource)115 self._available = False116class ArestSwitchPin(ArestSwitchBase):117 """Representation of an aREST switch. Based on digital I/O."""118 def __init__(self, resource, location, name, pin, invert):119 """Initialize the switch."""120 super().__init__(resource, location, name)121 self._pin = pin122 self.invert = invert123 request = requests.get(124 '{}/mode/{}/o'.format(self._resource, self._pin), timeout=10)125 if request.status_code != 200:126 _LOGGER.error("Can't set mode")127 self._available = False128 def turn_on(self, **kwargs):129 """Turn the device on."""130 turn_on_payload = int(not self.invert)131 request = requests.get(132 '{}/digital/{}/{}'.format(self._resource, self._pin,133 turn_on_payload),134 timeout=10)135 if request.status_code == 200:136 self._state = True137 else:138 _LOGGER.error(139 "Can't turn on pin %s at %s", self._pin, self._resource)140 def turn_off(self, **kwargs):141 """Turn the device off."""142 turn_off_payload = int(self.invert)143 request = requests.get(144 '{}/digital/{}/{}'.format(self._resource, self._pin,145 turn_off_payload),146 timeout=10)147 if request.status_code == 200:148 self._state = False149 else:150 _LOGGER.error(151 "Can't turn off pin %s at %s", self._pin, self._resource)152 def update(self):153 """Get the latest data from aREST API and update the state."""154 try:155 request = requests.get(156 '{}/digital/{}'.format(self._resource, self._pin), timeout=10)157 status_value = int(self.invert)158 self._state = request.json()['return_value'] != status_value159 self._available = True160 except requests.exceptions.ConnectionError:161 _LOGGER.warning("No route to device %s", self._resource)...

Full Screen

Full Screen

Resource.py

Source:Resource.py Github

copy

Full Screen

1# This file was automatically generated by SWIG (http://www.swig.org).2# Version 3.0.83#4# Do not make changes to this file unless you know what you are doing--modify5# the SWIG interface file instead.6from sys import version_info7if version_info >= (3, 0, 0):8 new_instancemethod = lambda func, inst, cls: _Resource.SWIG_PyInstanceMethod_New(func)9else:10 from new import instancemethod as new_instancemethod11if version_info >= (2, 6, 0):12 def swig_import_helper():13 from os.path import dirname14 import imp15 fp = None16 try:17 fp, pathname, description = imp.find_module('_Resource', [dirname(__file__)])18 except ImportError:19 import _Resource20 return _Resource21 if fp is not None:22 try:23 _mod = imp.load_module('_Resource', fp, pathname, description)24 finally:25 fp.close()26 return _mod27 _Resource = swig_import_helper()28 del swig_import_helper29else:30 import _Resource31del version_info32try:33 _swig_property = property34except NameError:35 pass # Python < 2.2 doesn't have 'property'.36def _swig_setattr_nondynamic(self, class_type, name, value, static=1):37 if (name == "thisown"):38 return self.this.own(value)39 if (name == "this"):40 if type(value).__name__ == 'SwigPyObject':41 self.__dict__[name] = value42 return43 method = class_type.__swig_setmethods__.get(name, None)44 if method:45 return method(self, value)46 if (not static):47 object.__setattr__(self, name, value)48 else:49 raise AttributeError("You cannot add attributes to %s" % self)50def _swig_setattr(self, class_type, name, value):51 return _swig_setattr_nondynamic(self, class_type, name, value, 0)52def _swig_getattr_nondynamic(self, class_type, name, static=1):53 if (name == "thisown"):54 return self.this.own()55 method = class_type.__swig_getmethods__.get(name, None)56 if method:57 return method(self)58 if (not static):59 return object.__getattr__(self, name)60 else:61 raise AttributeError(name)62def _swig_getattr(self, class_type, name):63 return _swig_getattr_nondynamic(self, class_type, name, 0)64def _swig_repr(self):65 try:66 strthis = "proxy of " + self.this.__repr__()67 except Exception:68 strthis = ""69 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)70try:71 _object = object72 _newclass = 173except AttributeError:74 class _object:75 pass76 _newclass = 077def _swig_setattr_nondynamic_method(set):78 def set_attr(self, name, value):79 if (name == "thisown"):80 return self.this.own(value)81 if hasattr(self, name) or (name == "this"):82 set(self, name, value)83 else:84 raise AttributeError("You cannot add attributes to %s" % self)85 return set_attr86class SwigPyIterator(object):87 thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')88 def __init__(self, *args, **kwargs):89 raise AttributeError("No constructor defined - class is abstract")90 __repr__ = _swig_repr91 __swig_destroy__ = _Resource.delete_SwigPyIterator92 def __iter__(self):93 return self94SwigPyIterator.value = new_instancemethod(_Resource.SwigPyIterator_value, None, SwigPyIterator)95SwigPyIterator.incr = new_instancemethod(_Resource.SwigPyIterator_incr, None, SwigPyIterator)96SwigPyIterator.decr = new_instancemethod(_Resource.SwigPyIterator_decr, None, SwigPyIterator)97SwigPyIterator.distance = new_instancemethod(_Resource.SwigPyIterator_distance, None, SwigPyIterator)98SwigPyIterator.equal = new_instancemethod(_Resource.SwigPyIterator_equal, None, SwigPyIterator)99SwigPyIterator.copy = new_instancemethod(_Resource.SwigPyIterator_copy, None, SwigPyIterator)100SwigPyIterator.next = new_instancemethod(_Resource.SwigPyIterator_next, None, SwigPyIterator)101SwigPyIterator.__next__ = new_instancemethod(_Resource.SwigPyIterator___next__, None, SwigPyIterator)102SwigPyIterator.previous = new_instancemethod(_Resource.SwigPyIterator_previous, None, SwigPyIterator)103SwigPyIterator.advance = new_instancemethod(_Resource.SwigPyIterator_advance, None, SwigPyIterator)104SwigPyIterator.__eq__ = new_instancemethod(_Resource.SwigPyIterator___eq__, None, SwigPyIterator)105SwigPyIterator.__ne__ = new_instancemethod(_Resource.SwigPyIterator___ne__, None, SwigPyIterator)106SwigPyIterator.__iadd__ = new_instancemethod(_Resource.SwigPyIterator___iadd__, None, SwigPyIterator)107SwigPyIterator.__isub__ = new_instancemethod(_Resource.SwigPyIterator___isub__, None, SwigPyIterator)108SwigPyIterator.__add__ = new_instancemethod(_Resource.SwigPyIterator___add__, None, SwigPyIterator)109SwigPyIterator.__sub__ = new_instancemethod(_Resource.SwigPyIterator___sub__, None, SwigPyIterator)110SwigPyIterator_swigregister = _Resource.SwigPyIterator_swigregister111SwigPyIterator_swigregister(SwigPyIterator)112def register_handle(handle, base_object):113 """114 Inserts the handle into the base object to115 prevent memory corruption in certain cases116 """117 try:118 if base_object.IsKind("Standard_Transient"):119 base_object.thisHandle = handle120 base_object.thisown = False121 except:122 pass123_Resource.Resource_SJIS_swigconstant(_Resource)124Resource_SJIS = _Resource.Resource_SJIS125_Resource.Resource_EUC_swigconstant(_Resource)126Resource_EUC = _Resource.Resource_EUC127_Resource.Resource_ANSI_swigconstant(_Resource)128Resource_ANSI = _Resource.Resource_ANSI129_Resource.Resource_GB_swigconstant(_Resource)...

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