예제 #1
0
def sendSms():
    """
    发送短信
    """
    d = Android()
    # 创建一个安卓运用实例
    
    d.smsSend("10086", "113")
    # 给10086发送短信查询代码
    
    time.sleep(5)
    # 暂停5秒,给手机一个发送时间
    
    sms_data=d.smsGetMessages(False, "inbox")
    # 读取短信
    
    latest_sms = sms_data.result[0]["body"]
    # 取得短信内容
    
    patterns = re.compile(r";已使用移动数据流量为(.*?);")
    flow = re.findall(patterns, latest_sms)
    # 只要流量部分
    
    if flow:
    # 要是匹配到表明查询成功,输出结果
        ydFlow = flow[0]
        print("已使用" + ydFlow)
예제 #2
0
파일: ppg.py 프로젝트: pouriya/ppg
 def write_buffer(text, log=True):
     from androidhelper import Android
     Android().setClipboard(text)
     if log:
         print(
             '{yellow}Password has been copied to clipboard{reset}'
             .format(**COLORS))
예제 #3
0
def locate():
    d = Android()

    d.startLocating()
    #time.sleep(3)

    loc = d.getLastKnownLocation().result['gps']
    if loc == None:
        gps = d.getLastKnownLocation().result['network']
    else:
        print('it is gps')
        gps = loc
    #print (loc)
    lngx = gps['longitude']
    lngy = gps['latitude']

    #ur='http://api.map.baidu.com/ag/coord/convert?from=0&to=4&x='+str(lngx)+'&y='+str(lngy)
    ur = 'http://apis.map.qq.com/ws/coord/v1/translate?locations=' + str(
        lngy) + ',' + str(
            lngx) + '&type=1&key=Y5YBZ-VLZCX-EQR4Y-Z47JH-TZCHQ-TXF7H'
    f = urlopen(ur).read()
    f = json.loads(f)

    #lngx=base64.b64decode(f['x'].encode())
    #lngy=base64.b64decode(f['y'].encode())
    #lngx=lngx.decode()
    #lngy=lngy.decode()

    #url='http://lbs.juhe.cn/api/getaddressbylngb?lngx='+str(lngx)+'&lngy'+str(lngy)

    #g=urlopen(url).read()
    #g=json.loads(g.decode())
    pos_lng = f['locations'][0]['lng']
    pos_lat = f['locations'][0]['lat']
    print(pos_lat)
    print(pos_lng)
    url = 'http://apis.map.qq.com/ws/geocoder/v1/?location=' + str(
        pos_lat) + ',' + str(
            pos_lng) + '&key=Y5YBZ-VLZCX-EQR4Y-Z47JH-TZCHQ-TXF7H&get_poi=1'
    g = urlopen(url).read()
    g = json.loads(g)
    addr = g[u'result'][u'formatted_addresses'][u'recommend']
    mess = addr.encode('utf-8')
    print(mess)

    #werobot.sendmess(addr)

    #g=json.loads(g.decode())
    #   print(f['locations'][0]['lat'])
    #  print(f['locations'][0]['lng'])
    global timer
    tt = 300 + random.uniform(0, 30)
    print(tt)
    timer = threading.Timer(tt, locate)
    timer.start()
예제 #4
0
파일: ppg.py 프로젝트: pouriya/ppg
def check_androidhelper():
    try:
        from androidhelper import Android
    except ImportError:
        return 'Could not import/found "androidhelper.Android" library.'
    try:
        # check lib functionality:
        Android().getClipboard().result
    except Exception as reason:
        return '"androidhelper" library is not working: {}'.format(str(reason))
    return True
예제 #5
0
def clipboard():
    try:
        print 'current clipboard() time:',time.asctime(time.localtime(time.time()))
        droid = Android()
        #setClipboard
        #droid.setClipboard("Hello World")
        #getClipboard
        cbstr = droid.getClipboard().result
        print cbstr
        if db <> None and cbstr<> None and len(cbstr)>0:
            sql="insert into info(createdby,comment) values('%s','%s')" % ('minlytask.clipboard',cbstr)
            db.ExecNonQuery(sql)
    except Exception,e:
        print e.message,traceback.format_exc()
예제 #6
0
def check_codelist(code_outFile):
    d = Android()
    # 发短信,未成功,qpython3采用sl4a成功
    d.smsSend('10086', 'test')
    # import sl4a
    # droid = sl4a.Android()
    # droid.smsSend("0044....","sms")

    # 获取短信数目
    Message_number = d.smsGetMessageCount(
        False).result  # False表示读取所有短信,True读取未读短信

    # 获取短信id
    Message_ids = d.smsGetMessageIds(True).result
    Message_ids = sorted(Message_ids, reverse=True)
    # print Message_ids

    if len(Message_ids) < 1:
        return []
    else:
        # 获取短信具体内容,默认读取收件箱内容,发送的信息使用参数'sent'
        sms_data = d.smsGetMessages(False, 'inbox').result
        message_body = []
        for message in sms_data:
            #print message["read"],message["type"],message["_id"]
            # if message["read"]!="1":
            if message["read"] != "0":
                continue
            elif message["type"] != "1":
                continue
            else:
                if int(message["_id"]) not in Message_ids[:5]:
                    continue
                else:
                    #print message["body"]
                    code_list = check_code(message["body"])
                    if len(code_list) >= 1:
                        for i in code_list:
                            message_body.append(str(i))
                    # message_body.append(message["body"].decode("unicode_escape"))
                    # message_body.append(message["body"].decode("unicode_escape"))
        write_message(code_outFile, sms_data)
        print message_body
        return message_body
예제 #7
0
    def locate(self):
        d = Android()  
        d.startLocating()  
        self.loc = d.getLastKnownLocation().result['gps']
        if self.loc == None:
            gps = d.getLastKnownLocation().result['network']
        elif self.loc == self.lastloc:
            gps = d.getLastKnownLocation().result['network']
        else:
            print('it is gps')
            gps = self.loc
        self.lastloc = self.loc
		
        self.lngx = gps['longitude']
        self.lngy = gps['latitude']
		
	self.translate()
	self.compare_station()
		
        tt=10
        self.timer=threading.Timer(tt,self.locate)
        self.timer.start()
예제 #8
0
def location():
    try:
        print 'current location() time:',time.asctime(time.localtime(time.time()))
        droid = Android()
        droid.startLocating()
        location = droid.getLastKnownLocation().result
        pprint.pprint(location)
        content = 'haiba:%s\tjdu:%s\twdu:%s\tspeed:%s\tprovider:%s\taccuracy:%s'
        gps = location.get('gps')
        network = location.get('gps')
        passive = location.get('gps')
        if gps<> None:
            altitude,longitude,latitude,speed,provider,accuracy=gps.get('altitude'),gps.get('longitude'),gps.get('latitude'),gps.get('speed'),gps.get('provider'),gps.get('accuracy')
            pprint.pprint(content % (altitude,longitude,latitude,speed,provider,accuracy))
        else:
            jdu,wdu,speed=0,0,0
        if network<> None:
            print content % (network.get('altitude'),network.get('longitude'),network.get('latitude'),network.get('speed'),network.get('provider'),network.get('accuracy'))
        if passive<> None:
            print content % (passive.get('altitude'),passive.get('longitude'),passive.get('latitude'),passive.get('speed'),passive.get('provider'),passive.get('accuracy'))
        location = location.get('network', location.get('gps'))
        wdu,jdu = location.get('latitude'),location.get('longitude')
        url=addressurl % (wdu,jdu)
        print url
        obj = common.url_jsonobj(url)
        print obj.get('queryLocation')
        addresslist = obj.get('addrList')
        for address in addresslist:
            if address.get('name')<>'':
                add =  'admCode:%s\tadmName:%s\t%s\ndistance:%s\tnearestPoint:%s\ttype:%s\tstatus:%s' % (address.get('admCode'),address.get('admName'),address.get('distance'),address.get('name'),address.get('nearestPoint'),address.get('type'),address.get('status'))
                print add
                if db <> None :
                    sql="insert into info(createdby,comment,altitude,longitude,latitude,speed,provider,accuracy) values('%s','%s',%f,%f,%f,%f,'%s',%d)" % ('minlytask.location',add,altitude,longitude,latitude,speed,provider,accuracy)
                    db.ExecNonQuery(sql)

    except Exception,e:
        print e.message,traceback.format_exc()
예제 #9
0
#-*-coding:utf8;-*-
#qpy:2
#qpy:console
#import nltk
import time
import json
import os
from androidhelper import Android
droid=Android()
def get_data(item,property,query):
	data_dir=os.getcwd()
	js=data_dir+"/scripts/ai_chatbot/data/"+query+".json"
	js_data=[]
	
		
	with open(js,"r") as f:
		content=f.read()
		j_data=json.loads(content)
		t=j_data[item]
		q=False
		for p in property:
			q=p
			
		for x in t:
			js_data.append(x[property[0]][property[1]].encode("UTF-8").strip().replace("["," ").replace("]"," ").replace('"',' '))
		#print str("\n". join(js_data))
			
	return str("\n". join(js_data))
def get_array_data(item,property,query):
	data_dir=os.getcwd()
	js=data_dir+"/scripts/ai_chatbot/data/"+query+".json"
예제 #10
0
def sms():
    droid = Android()
    s=droid.smsSend("15919147090","测试")
예제 #11
0
파일: wifi.py 프로젝트: wayrou/Archive
import ks
from androidhelper import Android
andro = Android()

if (not andro.checkWifiState().result and ks.yesNo("Turn Wi-Fi on?")):
    andro.toggleWifiState()
elif (not andro.checkWifiState().result):
    exit()


def scanResults():
    if (andro.wifiGetConnectionInfo().result['network_id'] != -1):
        return andro.wifiGetConnectionInfo().result
    for result in andro.wifiGetScanResults().result:
        print("\n")
        for key in result:
            print(key, " : ", result[key])
    return 0


a = scanResults()
if (a):
    print(a)
예제 #12
0
#qpy:3
#qpy:console
'''
Criado por Kevin
e-mail: [email protected]
'''
## parte do app no cell
from androidhelper import Android
from time import ctime
dr = Android()
voluntarios = []
##


class Voluntario:
    def __init__(self, num):
        self.numero = num
        self.entrada = ctime()
        self.saida = 0

    def baterSaida(self):
        self.saida = ctime()


##def funcçao que atribui o valor lido do barcode para delattr


def loadData():
    arq = open(NomeDoArquivo)
    a = arq.readlines()
    arq.close()
예제 #13
0
 def __init__(self):
     self.regex = re.compile('证码为.*【(\d+)】')  # regex
     self.start_time = datetime.datetime.now()
     # Android QPython3
     self.droid = Android()
     logging.debug("QPython3 实例初始化完成")
예제 #14
0
 def __init__(self):
     # It can break the command and control server if the import is not here
     from androidhelper import Android
     self.droid = Android()
예제 #15
0
while True:
    op = input("Texto para binario ou binário para texto?(1/2) ")
    if op in ["1", "2"]:
        break

while True:
    opd = input("Quer colar?(s/n) ")
    if opd in ["s", "n"]:
        break

copied = opd == "s"

if op == "1":
    if copied:
        texto = Android().getClipboard().result.strip()
        print("Você colou:", texto)
    else:
        texto = input("Digite o texto que vai ser convertido: ").strip()
    saida = []
    for char in texto:
        saida.append(text_bin(char))
    v = " ".join(saida)
else:
    if copied:
        codigo = Android().getClipboard().result.strip()
        print("Você colou:", codigo)
    else:
        codigo = input("Diga o código binário: ").strip()
    codigo = "".join([i for i in codigo if i in ["0", "1"]])
    assert len(
예제 #16
0
 def __init__(self):
     self.midiout_notes = Android()
     for i in range(21, 108 + 1):
         self.midiout_notes.mediaPlay(self.PRENAME + str(i) + self.POSTNAME,
                                      str(i), False)
예제 #17
0
from androidhelper import Android
import time
import os
import datetime
import math


def getDistance(dlat, dlon):
    unit = math.pi * 6371000 / 180
    y = dlat * unit
    x = dlon * unit * math.sin(dlat)
    return math.hypot(x, y)


drd = Android()

drd.wakeLockAcquirePartial()
drd.startLocating(100, 2)

os.system("clear")
print("Waiting for location data ...")
while 1:
    res = drd.readLocation().result
    if res:
        break
    time.sleep(0.1)

old = None
distance = 0
oldpos = None
start = None
예제 #18
0
파일: ppg.py 프로젝트: pouriya/ppg
 def load_last_buffer():
     from androidhelper import Android
     return Android().getClipboard().result