Exemplo n.º 1
0
def main():

	mobile = account.mobile
	hostname = 'localhost'
	port = 8765
	password = account.password

	fetion = Fetion(mobile, password)
	fetion.get_system_config()
	try:
		fetion.login_ssi()
		print "get it"
	except:
		print "fail"

	factory = FetionClientFactory(fetion)
	reactor.connectTCP(fetion.sipc_proxy, fetion.sipc_proxy_port, factory)
	print 'Connected to %s:%s' % (fetion.sipc_proxy, fetion.sipc_proxy_port)
	reactor.run()
Exemplo n.º 2
0
def main():
    # create a options parser
    parser = OptionParser()
    parser.add_option('-m', '--mobile', dest='mobile', type='string',
                      help='mobile phone number')
    parser.add_option('-p', '--password', dest='password', type='string',
                      help='login password')
    parser.add_option('-H', '--host', dest='hostname', type='string',
                      default='localhost',
                      help='specify hostname to run on, default is localhost')
    parser.add_option('-P', '--port', dest='port', type='int',
                      default=8765, help='port number to run on, default is 8765')

    (options, args) = parser.parse_args()

    # handle options
    if not options.mobile:
        parser.error('-m option is required')

    mobile = options.mobile
    hostname = options.hostname
    port = options.port
    if not options.password:
        password = getpass()
    else:
        password = options.password

    fetion = Fetion(mobile, password)
    fetion.get_system_config()
    fetion.login_ssi()

    factory = FetionClientFactory(fetion)
    daemon = server.Site(HTTPDaemon(factory))
    reactor.connectTCP(fetion.sipc_proxy, fetion.sipc_proxy_port, factory)
    print 'Connected to %s:%s' % (fetion.sipc_proxy, fetion.sipc_proxy_port)
    reactor.listenTCP(port, daemon, interface=hostname)
    print 'Listening %s:%s' % (hostname, port)
    reactor.run()
Exemplo n.º 3
0
gpa = connect.get_gpa()
for x in gpa:
    s = ''
    for y in x:
        s += y + '\t'
    print s
write_log(gpa)
# gpa = []

del connect

# Get the fetion password and try to send a message.
fet_user = '******'
fet_pwd = getpass.getpass('请输入飞信密码:')
fet = Fetion(fet_user, fet_pwd)
fet.send_msg('此短信仅为验证飞信密码、功能是否正常!')
# Delete to logout. Avoid affecting the normal use of fetion.
del fet

while True:
    time.sleep(60)

    connect = FduConnect(username, password)

    result = connect.get_exercise()
    if len(result) == len(exercise) and set(result) != set(exercise):
        # The information of exercise has changed. Notify the user.
        print 'New exercise!'
        fet = Fetion(fet_user, fet_pwd)
        # print '您的体锻有更新!' + get_diff_exercise(result, exercise)