.doc to pdf using python

A simple example using comtypes, converting a single file, input and output filenames given as commandline arguments: import sys import os import comtypes.client wdFormatPDF = 17 in_file = os.path.abspath(sys.argv[1]) out_file = os.path.abspath(sys.argv[2]) word = comtypes.client.CreateObject(‘Word.Application’) doc = word.Documents.Open(in_file) doc.SaveAs(out_file, FileFormat=wdFormatPDF) doc.Close() word.Quit() You could also use pywin32, which would be the same except for: import … Read more

Selenium waitForElement

From the Selenium Documentation PDF : import contextlib import selenium.webdriver as webdriver import selenium.webdriver.support.ui as ui with contextlib.closing(webdriver.Firefox()) as driver: driver.get(‘http://www.google.com’) wait = ui.WebDriverWait(driver,10) # Do not call `implicitly_wait` if using `WebDriverWait`. # It magnifies the timeout. # driver.implicitly_wait(10) inputElement=driver.find_element_by_name(‘q’) inputElement.send_keys(‘Cheese!’) inputElement.submit() print(driver.title) wait.until(lambda driver: driver.title.lower().startswith(‘cheese!’)) print(driver.title) # This raises # selenium.common.exceptions.TimeoutException: Message: None # … Read more

Stored procedure that Automatically delete rows older than 7 days in MYSQL

Mysql has its EVENT functionality for avoiding complicated cron interactions when much of what you are scheduling is sql related, and less file related. See the Manual page here. Hopefully the below reads as a quick overview of the important steps and things to consider, and verifiable testing too. show variables where variable_name=”event_scheduler”; +—————–+——-+ | … Read more

Best practice – Git + Build automation – Keeping configs separate

That is called content filter driver, and it allows you to declare, in a .gitattributes file (and only for your config files type) a smudge script which will automatically on checkout: combine a config file template file (config.tpl) with the right config file value (config.dev, config.prod, …) in order to produced a non-versioned config file … Read more

headless internet browser? [closed]

Here are a list of headless browsers that I know about: HtmlUnit – Java. Custom browser engine. Limited JavaScript support/DOM emulated. Open source. Ghost – Python only. WebKit-based. Full JavaScript support. Open source. Twill – Python/command line. Custom browser engine. No JavaScript. Open source. PhantomJS – Command line/all platforms. WebKit-based. Full JavaScript support. Open source. … Read more

Python. Function testing using Nose

In this .py file you should write import nose.tools as nt from checkers import is_triangle def test_is_triangle(): # Define test_a, test_b, and test_c here such that they should produce a # return value of False. nt.assert_false(is_triangle(test_a, test_b, test_c)) # Redefine test_a, test_b, and test_c here such that they should produce a # return value of … Read more