I'm testing various smartphones using AndroidViewClient.
To prevent connection errors, I used connection options(kwargs1, kwargs2) as follows.
from com.dtmilano.android.viewclient import *
from com.dtmilano.android.adb.adbclient import *
kwargs1 = {'ignoresecuredevice': True}
kwargs2 = {'startviewserver': False, 'autodump': False}
vc = ViewClient(*ViewClient.connectToDeviceOrExit(**kwargs1), **kwargs2)
device, serialno = vc.device, vc.serialno
adb = AdbClient(serialno=serialno)
MODEL = adb.getProperty('ro.product.model')
print 'MODEL :', MODEL
So, connection errors disappeared.
But some phones with special serial number(such as 'LG-F160S-e0a852', 'EF47S01111100117300', ...) raised following serialno error.
Traceback (most recent call last):
File "D:\$Project\Eclipse\_Python\AutoTest\01_get_property4.py", line 43, in <module>
adb = AdbClient(serialno=serialno)
File "D:\$Project\Eclipse\AndroidViewClient-master\src\com\dtmilano\android\adb\adbclient.py", line 108, in __init__
self.__setTransport()
File "D:\$Project\Eclipse\AndroidViewClient-master\src\com\dtmilano\android\adb\adbclient.py", line 251, in __setTransport
raise RuntimeError("ERROR: couldn't find device that matches '%s'" % self.serialno)
RuntimeError: ERROR: couldn't find device that matches '8b1ac56e'
How can I get correct serialno or prevent this error?
Related
I'm trying to create my MCP workspace, however, I run into a problem when I run decompile.sh (creates all files). When I run the sh file, it gives me a python error.
Traceback (most recent call last):
File "runtime/decompile.py", line 58, in decompile
commands = Commands(conffile, verify=True, no_patch=no_patch, workdir=workdir, json=json)
File "/Users/louie/Desktop/louie/mcp918/runtime/commands.py", line 176, in __init__
normalStart = self.readconf(workdir, json)
File "/Users/louie/Desktop/louie/mcp918/runtime/commands.py", line 565, in readconf
self.mcLibraries = MinecraftDiscovery.getLibraries(mcDir, self.jsonFile, osKeyword)
File "/Users/louie/Desktop/louie/mcp918/runtime/MinecraftDiscovery.py", line 157, in getLibraries
libFilename = "%s-%s-%s.jar"%(libSubdir, libVersion, substitueString(library['natives'][osKeyword]))
File "/Users/louie/Desktop/louie/mcp918/runtime/MinecraftDiscovery.py", line 185, in substitueString
str = str.replace("${arch}", getArch())
TypeError: coercing to Unicode: need string or buffer, NoneType found
louie#Louies-MBP mcp918 %
Any idea of how to fix this?
OS: Mac
I have python 3 installed
I have java 8 installed
Here's the failing code:
def getArch():
machine = platform.machine()
if os.name == 'nt' and sys.version_info[:2] < (2,7):
machine = os.environ.get("PROCESSOR_ARCHITEW6432", os.environ.get('PROCESSOR_ARCHITECTURE', ''))
machine2bits = {'AMD64': '64', 'x86_64': '64', 'i386': '32', 'x86': '32'}
return machine2bits.get(machine, None)
def substitueString(str):
str = str.replace("${arch}", getArch())
return str
Since you're on an Apple Silicon Mac, you're on the ARM architecture, which MCP918 doesn't support. (This shouldn't be a surprise, since Apple Silicon wasn't released until 5 years after MCP918 was.)
i am trying to send the file below '105.8k' to my energy meter.
i am using the xmodem example from pypi but i get the following error:
Traceback (most recent call last):
File "C:\Py\mainpy.py", line 68, in <module>
status = modem.send(f, retry=3)
File "C:\Users\admin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\xmodem\__init__.py", line 270, in send
char = self.getc(1)
File "C:\py\mainpy.py", line 62, in getc
return ser.read(size) or None
AttributeError: 'str' object has no attribute 'read'
the code i use:
### send file to port###
ser = serialPortCombobox.get().split(" ")[0]
def getc(size, timeout=1):
return ser.read(size) or None
def putc(data, timeout=1):
return ser.write(data)
modem = XMODEM(getc, putc)
f = open('105.8k', 'rb')
status = modem.send(f, retry=3)
ser.close()
stream.close()
thank you for your help.
I am new to python and want to know alternate way for doing the following.
I am having issue with the exec_command of paramiko...
Following is the code:
sshdell = paramiko.SSHClient()
sshdell.set_missing_host_key_policy(paramiko.AutoAddPolicy())
sshdell.connect('ip', port=22, username='user', password='pwd')
stdin,stdout,stderr = sshdell.exec_command("ping 4.2.2.2 interface X1")
ping_check = stdout.readlines()
for line in ping_check:
print(line)
the given error is thrown.
Traceback (most recent call last):
File "delltest.py", line 36, in <module>
stdin,stdout,stderr = sshdell.exec_command("ping 4.2.2.2 interface X1")
File "C:\python35\lib\site-packages\paramiko\client.py", line 441, in exec_command
chan.exec_command(command)
File "C:\python35\lib\site-packages\paramiko\channel.py", line 60, in _check
return func(self, *args, **kwds)
File "C:\python35\lib\site-packages\paramiko\channel.py", line 234, in exec_command
self._wait_for_event()
File "C:\python35\lib\site-packages\paramiko\channel.py", line 1161, in _wait_for_event
raise e
paramiko.ssh_exception.SSHException: Channel closed.
Please suggest as my device may not support the exec_command() function.
APScheduler (3.3.1) py2.7
I use this code to do my job When I use Memory as job store it can work well but I have too many job and my Memory in server is limit so I change SQLAlchemyJobStore as job store but I got the Lookup error. How to solve it.
Code:
def script(indicator, strategy_name, real_time=False):
# Solve No handlers could be found for logger “apscheduler.scheduler
import logging
logging.basicConfig(level=logging.ERROR,
format='%(name)-12s %(asctime)s %(levelname)-8s %(message)s',
datefmt='%a, %d %b %Y %H:%M:%S')
try:
job_defaults = {
'coalesce': False,
'max_instances': 1,
"misfire_grace_time": config.real_time_script_interval + 5,
}
executors = {
'default': ThreadPoolExecutor(60),
}
jobstores = {
"default": SQLAlchemyJobStore(url='sqlite:///jobs.sqlite')
}
scheduler = BlockingScheduler(daemonic=True, jobstores=jobstores, job_defaults=job_defaults,
executors=executors)
module = __import__("%s.%s" % (indicator, strategy_name), fromlist=[strategy_name])
if real_time:
for st in module.strategy:
scheduler.add_job(st.run, "interval", seconds=config.real_time_script_interval)
else:
for st in module.strategy:
# 计算最近的下一个准点时间
start_time = _recent_time(st.run_period)
scheduler.add_job(st.run, "interval", **start_time)
scheduler.start()
except Exception as e:
logger.get("run-log").error(error_msg())
Error:
apscheduler.jobstores.default Thu, 06 Apr 2017 10:50:32 ERROR Unable to restore job "d100a4b24e2d49c3ad51305fd846e5f5" -- removing it
Traceback (most recent call last):
File "/Users/wyx/bitcoin_workspace/fibo-strategy/.env/lib/python2.7/site-packages/apscheduler/jobstores/sqlalchemy.py", line 135, in _get_jobs
jobs.append(self._reconstitute_job(row.job_state))
File "/Users/wyx/bitcoin_workspace/fibo-strategy/.env/lib/python2.7/site-packages/apscheduler/jobstores/sqlalchemy.py", line 122, in _reconstitute_job
job.__setstate__(job_state)
File "/Users/wyx/bitcoin_workspace/fibo-strategy/.env/lib/python2.7/site-packages/apscheduler/job.py", line 260, in __setstate__
self.func = ref_to_obj(self.func_ref)
File "/Users/wyx/bitcoin_workspace/fibo-strategy/.env/lib/python2.7/site-packages/apscheduler/util.py", line 277, in ref_to_obj
raise LookupError('Error resolving reference %s: error looking up object' % ref)
LookupError: Error resolving reference base.strategy:Strategy.run: error looking up object
apscheduler.jobstores.default Thu, 06 Apr 2017 10:50:32 ERROR Unable to restore job "2602167cd3c745c2b0764a2b63da1a3a" -- removing it
Traceback (most recent call last):
File "/Users/wyx/bitcoin_workspace/fibo-strategy/.env/lib/python2.7/site-packages/apscheduler/jobstores/sqlalchemy.py", line 135, in _get_jobs
jobs.append(self._reconstitute_job(row.job_state))
File "/Users/wyx/bitcoin_workspace/fibo-strategy/.env/lib/python2.7/site-packages/apscheduler/jobstores/sqlalchemy.py", line 122, in _reconstitute_job
job.__setstate__(job_state)
File "/Users/wyx/bitcoin_workspace/fibo-strategy/.env/lib/python2.7/site-packages/apscheduler/job.py", line 260, in __setstate__
self.func = ref_to_obj(self.func_ref)
File "/Users/wyx/bitcoin_workspace/fibo-strategy/.env/lib/python2.7/site-packages/apscheduler/util.py", line 277, in ref_to_obj
raise LookupError('Error resolving reference %s: error looking up object' % ref)
LookupError: Error resolving reference base.strategy:Strategy.run: error looking up object
apscheduler.jobstores.default Thu, 06 Apr 2017 10:50:32 ERROR Unable to restore job "3eb917670e7642b8848a165268df8913" -- removing it
Traceback (most recent call last):
File "/Users/wyx/bitcoin_workspace/fibo-strategy/.env/lib/python2.7/site-packages/apscheduler/jobstores/sqlalchemy.py", line 135, in _get_jobs
jobs.append(self._reconstitute_job(row.job_state))
File "/Users/wyx/bitcoin_workspace/fibo-strategy/.env/lib/python2.7/site-packages/apscheduler/jobstores/sqlalchemy.py", line 122, in _reconstitute_job
job.__setstate__(job_state)
File "/Users/wyx/bitcoin_workspace/fibo-strategy/.env/lib/python2.7/site-packages/apscheduler/job.py", line 260, in __setstate__
self.func = ref_to_obj(self.func_ref)
File "/Users/wyx/bitcoin_workspace/fibo-strategy/.env/lib/python2.7/site-packages/apscheduler/util.py", line 277, in ref_to_obj
raise LookupError('Error resolving reference %s: error looking up object' % ref)
LookupError: Error resolving reference base.strategy:Strategy.run: error looking up object
Supplementary instruction for Alex Grönholm's question here because it is hard to say in comment
In base/strategy_util.py:
base_strategy is some classes which inherit the BaseStrategy class in base/strategy.py . The BaseStrategy has its run method
def _strategy(base_strategy, minute, ticker_table_format):
class Strategy(base_strategy):
run_period = minute
def _init_params(self):
self.ticker_table_format = ticker_table_format
return Strategy()
def _create_strategy(base_strategy, minute_list=ALL_MINUTE):
strategy_list = []
for minute in minute_list:
for ticker_table_format in const.TICKER_TABLE_FORMAT.ALL:
st = _strategy(base_strategy, minute, ticker_table_format)
strategy_list.append(st)
return strategy_list
def ma_strategy(base_strategy):
return _create_strategy(base_strategy)
In MA/touch_avg.py:
MA_TOUCH_AVG inherit the BaseStrategy class
from base.strategy import MA_TOUCH_AVG
from base.strategy_util import ma_strategy
strategy = ma_strategy(MA_TOUCH_AVG)
And then I use click to call the strategy like python run_strategy.py run MA touch_avg
In run_strategy.py:
#cli.command()
#click.argument('indicator')
#click.argument('strategy_name')
def run(indicator, strategy_name):
""" run indicator strategy_name """
real_time_strategy_name = ["touch_avg", "limit"]
util.script(indicator, strategy_name,
real_time=strategy_name in real_time_strategy_name)
The reason you're having this problem is because you create a class dynamically, in a function. APScheduler stores the reference to the scheduled function as module:varname. How is the scheduler expected to find a class that you're making on the fly in a function?
I am trying to get the usb.find command to work properly in a python script I'm writing on Angstrom for the Beagleboard.
Here is my code:
#!/usr/bin/env python
import usb.core
import usb.util
import usb.backend.libusb01 as libusb
PYUSB_DEBUG_LEVEL = 'debug'
# find our device
# Bus 002 Device 006: ID 1208:0815
# idVendor 0x1208
# idProduct 0x0815
# dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)
# iManufacturer 1 TOROBOT.com
dev = usb.core.find(idVendor=0x1208, idProduct=0x0815,
backend=libusb.get_backend() )
I don't know what's missing, but here is what I do know.
When I don't specify the backend, no backend is found. When I do specify the backend usb.backend.libusb01 I get the following error:
root#beagleboard:~/servo# ./pyServo.py
Traceback (most recent call last):
File "./pyServo.py", line 17, in <module>
dev = usb.core.find(idVendor=0x1208, idProduct=0x0815, backend=libusb.get_backend() )
File "/usr/lib/python2.6/site-packages/usb/core.py", line 854, in find
return _interop._next(device_iter(k, v))
File "/usr/lib/python2.6/site-packages/usb/_interop.py", line 60, in _next
return next(iter)
File "/usr/lib/python2.6/site-packages/usb/core.py", line 821, in device_iter
for dev in backend.enumerate_devices():
File "/usr/lib/python2.6/site-packages/usb/backend/libusb01.py", line 390, in enumerate_devices
_check(_lib.usb_find_busses())
File "/usr/lib/python2.6/ctypes/__init__.py", line 366, in __getattr__
func = self.__getitem__(name)
File "/usr/lib/python2.6/ctypes/__init__.py", line 371, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python: undefined symbol: usb_find_busses
What am I missing so that this will work properly?
Try installing python-pyusb through opkg, that should install the native dependencies.