def run_lyndor_bat(): ''' create Run-Lyndor.bat in windows ''' os.chdir(read.LYNDOR_PATH) bulk_download = open('Bulk Download.txt', 'w') bulk_download.close() shutil.move( 'Bulk Download.txt', read.settings_json('preferences', 'location') + '/Bulk Download.txt') print('-> Bulk Download.txt file created successfully.\n') if install.check_os() == 'windows': run_path = 'python "' + os.getcwd() + '/run.py"' lynda = open('Run-Lyndor.bat', 'a') lynda.writelines('@ECHO OFF\n') lynda.writelines('REM Batch file to execute run.py\n') lynda.writelines('SET PATH=%PATH%;C:\Python27;C:\Python27\Scripts\n') lynda.writelines(run_path + '\n') lynda.writelines('pause') lynda.close() try: os.rename( 'Run-Lyndor.bat', read.settings_json('preferences', 'location') + '/Run-Lyndor.bat') except: pass finally: print('-> Run-Lyndor.bat file created.\n')
def aria2(): ''' Download aria2c for windows ''' try: import requests except ImportError: pass os.chdir(install.LYNDOR_PATH) if install.check_os() == 'windows': try: os.mkdir('aria2c') except: pass aria = requests.get( 'https://github.com/aria2/aria2/releases/download/release-1.33.1/aria2-1.33.1-win-64bit-build1.zip' ) print('\n-> Downloading aria2c for windows') with open('./aria2c/aria2c.zip', 'wb') as f: f.write(aria.content) print( '\n>>> aria2c.zip has been downloaded inside "Lyndor/aria2c" folder' ) unzip('aria2c', 'aria2c.zip') print( '>>> aria2c.zip has been unzipped, copy its path and save to PATH variable.\n' )
def webdriver(): ''' Download web driver ''' try: import requests except ImportError: pass os.chdir(install.LYNDOR_PATH) # change directory to LYNDOR try: # create directory webdriver to save platform specific webdrivers os.mkdir('webdriver') except: pass print('\n-> Downloading web driver for', install.check_os()) if install.check_os() == 'windows': chrome_url = 'https://chromedriver.storage.googleapis.com/2.35/chromedriver_win32.zip' firefox_url = 'https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-win64.zip' elif install.check_os() == 'macos': chrome_url = 'https://chromedriver.storage.googleapis.com/2.35/chromedriver_mac64.zip' firefox_url = 'https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-macos.tar.gz' elif install.check_os() == 'linux': chrome_url = 'https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip' firefox_url = 'https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-linux64.tar.gz' chrome = requests.get(chrome_url) firefox = requests.get(firefox_url) with open('webdriver/chromedriver.zip', 'wb') as f: f.write(chrome.content) with open('webdriver/firefoxdriver.zip', 'wb') as f: f.write(firefox.content) print( '\n>>> Web driver downloaded inside "/Lyndor/webdriver" folder, extract the zip file and \ set the webdriver directory path to "PATH" variable, see README.md file for more detail.' ) print( '\n>>> Installation complete update your settings by running "python settings/settings.py"' ) print( '\nThis will run a local webserver at port 5000, you will see a message like' ) print( '* Running on http://127.0.0.1:5000/ visit such URL in web-browser\n')
def aliases_bat(): '''Create aliases file''' os.chdir(read.LYNDOR_PATH) if install.check_os() == 'windows': run_path = 'doskey lynda= python "' + os.getcwd() + '/run.py"' alias = open('aliases.bat', 'w') alias.write(run_path) alias.close() print('-> aliases.bat file created.\n')
def webdriver(): ''' Download web driver ''' import requests os.chdir(read.LYNDOR_PATH) # change directory to LYNDOR try: # create directory webdriver to save platform specific webdrivers os.mkdir('webdriver') except: pass print('\n-> Downloading web driver for ' + install.check_os()) if install.check_os() == 'windows': chrome_url = 'https://chromedriver.storage.googleapis.com/2.35/chromedriver_win32.zip' firefox_url = 'https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-win64.zip' elif install.check_os() == 'macos': chrome_url = 'https://chromedriver.storage.googleapis.com/2.35/chromedriver_mac64.zip' firefox_url = 'https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-macos.tar.gz' elif install.check_os() == 'linux': chrome_url = 'https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip' firefox_url = 'https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-linux64.tar.gz' chrome = requests.get(chrome_url) firefox = requests.get(firefox_url) with open('webdriver/chromedriver.zip', 'wb') as f: f.write(chrome.content) with open('webdriver/firefoxdriver.zip', 'wb') as f: f.write(firefox.content) print( '\n>>> Web driver downloaded inside "/Lyndor/webdriver" folder, extract the zip file and\ set the webdriver directory path to "PATH" variable, see README.md file for more detail.\n' ) print( '\n>>> Installation complete, Don\'t forget to have a look at settings.json\n' )