# ...... D:\Github\ict_autoconnect>python setup.py yield "store", (names[oparg],) IndexError: tuple index out of range
细心的我去stackoverflow查了一下 传送门:python-indexerror-tuple-index-out-of-range-when-using-py2exe The bytecode often changes in small ways from version to version that could break even Python 3.5 (given only 3.3 and 3.4 support is claimed explicitly), but 3.6 is 100% guaranteed to fail.
5 missing Modules ------------------ ? netbios imported from uuid ? readline imported from cmd, code, pdb ? win32api imported from platform ? win32con imported from platform ? win32wnet imported from uuid Building 'dist\login.exe'. Building shared code archive 'dist\library.zip'. Copy c:\programdata\anaconda3\envs\python3.3\python33.dll to dist Copy C:\ProgramData\Anaconda3\envs\python3.3\DLLs\unicodedata.pyd to dist\unicodedata.pyd Copy C:\ProgramData\Anaconda3\envs\python3.3\DLLs\_lzma.pyd to dist\_lzma.pyd Copy C:\ProgramData\Anaconda3\envs\python3.3\DLLs\_ctypes.pyd to dist\_ctypes.pyd Copy C:\ProgramData\Anaconda3\envs\python3.3\DLLs\_bz2.pyd to dist\_bz2.pyd Copy C:\ProgramData\Anaconda3\envs\python3.3\DLLs\_hashlib.pyd to dist\_hashlib.pyd Copy C:\ProgramData\Anaconda3\envs\python3.3\DLLs\_socket.pyd to dist\_socket.pyd Copy C:\ProgramData\Anaconda3\envs\python3.3\DLLs\_ssl.pyd to dist\_ssl.pyd Copy C:\ProgramData\Anaconda3\envs\python3.3\DLLs\pyexpat.pyd to dist\pyexpat.pyd Copy C:\ProgramData\Anaconda3\envs\python3.3\DLLs\select.pyd to dist\select.pyd Copy DLL C:\ProgramData\Anaconda3\envs\python3.3\MSVCR100.dll to dist\
#coding=utf8 # ======================================================== # Copyright (C) 2017 All rights reserved. # # filename : CDLogin.py # author : chendian@baidu.com # date : 2017-08-29 # desc : Auto_Login Test # ========================================================
import os import time import selenium from selenium import webdriver
import platform # "Windows" or "Linux" OS_TYPE = platform.system()
defauto_connect(un, pw): print('open a phantomJS browser...\n') try: browser = webdriver.PhantomJS() except selenium.common.exceptions.WebDriverException as e: # Message: 'phantomjs' executable needs to be in PATH. print("Current Version only contains Windows PhantomJS.") print("You need phantomJS for your own platform as <%s>" % OS_TYPE) print("Please visit http://phantomjs.org/download.html for downloading") print("Download and unzip and find PhantomJS, copy it beside this python file.") print("For further info, visit http://blog.csdn.net/okcd00/article/details/77677326#t10") os.system('pause') exit() browser.get('http://159.226.39.22')
print('waiting 10s for posting...') time.sleep(10) browser.close()
defread_conf(): un = '' pw = '' ps = '' try: withopen('user.conf', 'r') as file: for line in file.readlines(): line = line.strip() if line == '': continue if line[0] == '#': continue if line.split('=')[0].strip() == 'username': un = line.split('=')[1].strip() elif line.split('=')[0].strip() == 'password': pw = line.split('=')[1].strip() elif line.split('=')[0].strip() == 'pingsite': ps = line.split('=')[1].strip() else: print('user.conf is a error format. \n') except IOError as e: print('cannot read user.conf file--' + str(e) + ', please create user.conf file. \n') return un, pw, ps
defis_connect(ps): if OS_TYPE == 'Windows': flag = os.system('ping ' + ps) elif OS_TYPE == 'Linux': flag = os.system('ping -c 3 ' + ps) if flag == 0: returnTrue returnFalse
defcon_connect(un, pw, ps): if is_connect(ps): return1 else: auto_connect(un, pw) if is_connect(ps): print('\nConnect internet success.\n') else: print('\nConnect internet Failed.\n') return1
if __name__ == '__main__': print("starting...") os.system('MODE con: COLS=128 LINES=32 & TITLE Welcome to CDLogin') from logo import show_logo # show_logo() os.system('cls') time.sleep(1) os.system("color 0A") os.system('MODE con: COLS=64 LINES=16 & TITLE CD_Auto_Login is working') un, pw, ps = read_conf() while1: print('=== current time ===') os.system("DATE /T & TIME /T") print('If you want to stop, input Ctrl+C to break.') con_connect(un, pw, ps) print('\nNext check in 10 mins ...\n') time.sleep(10*60) #Test os.system('cls')
if __name__ == '__main__': if uname == "lihongwei_test": print"please set username, password and ip!" else: whileTrue: ifnot internet_on(): logout_login() time.sleep(interval_time)
UpdateLog
[2017/09/04] ver 1.1.0 (Author: @lhw446, Original: @cyx)
Add single file script.
[2017/08/29] ver 1.0.1 (Feat: @lhw446)
Add guide for downloading and setting phantomJS
Add available platforms (MAC platform as Linux, maybe Darwin)