I am developing PyTiCroque which is python + Qt based software. The main platforms are Linux and Windows.
When I am close to final release, getting the release in shape usually goes through several attempts: I generate one release file, test it, find a bug, fix it, generate another release file and here we go again.
Of course, I have automated most of the process. I have a small python script make_exe.py that take care of most of the it: exe building on windows with PyInstaller, then installer building with InnoSetup.
There is one step that I had not automated so far: uploading the release file to RedMine. I used to go through manual upload but for the last release, I had to release the file several times and was annoyed by this last manual step. Surely, there is something I can do to automate this.
It’s been a long time that I wanted to touch web scraping and web automation. After a quick search, I found mechanize and it did the job very well. The doc are a bit strange, with no autogenerated docs, and just example on the website, but the tool is so simple to use that it was not much of a problem.
In 15 minutes, I had my script running:
- Login to Redmine
- Go to the File Upload page
- Enter the information for the new file: filename, mimetype, release attached to the file
- upload it
The final script is:
url_fh = 'http://labs.freehackers.org/'
br = mechanize.Browser()
br.set_handle_robots(False)
report( 'Fetching labs.freehackers.org/login page...' )
page = br.open( url_fh + 'login' )
report( 'Logging in...' )
br.select_form( nr=1 )
br["username"]="philippe"
br["password"]="XXXXXX"
br["autologin"]=0
page = br.submit()
report( 'Opening PyTiCroque - New Files page...' )
page = br.open( url_fh + 'projects/pyticroque/files/new' )
report( 'Registering the file' )
br.select_form( nr=1 )
br["version_id"]= [ "44" ]
br.add_file( open( r'd:\work\pyticroque-dev\pyticroque\LISEZMOI.txt' ), "text/plain", "LISEZMOI.txt" )
page = br.submit()
report( 'File sumitted !' )
The process is so simple that I plan to automate more stuff in the future. For example, my users are so not computer savy that doing through a bug reporting software is too much for them. Still, I like good bug reports. I have a log file that gives me accurate information about everything that happened in the software, so if they can attach that file to the bug report, I can probably find the bug. But attaching a file to a bug report is not so simple for non computer savvy people. Instead, what I plan to do is automate the process of bug reporting with a wizard. They will go through the following steps:
- You want to report a bug ?
- You want to be notified of updates ? If so, please enter your email address ?
- Click [Send bug report]
Behind the scene, I will connect to Redmine, identify the right version, prepare the bug report form, attach the log file and enter it in the bug manager. I hope I can get the bug reports then !





Home