Skip to content
Browse files

initial commit

  • Loading branch information...
0 parents commit 25c8b973802837bcf25fffd469b5419a803fa487 @gaving committed with Gavin Gilmour Jan 25, 2011
Showing with 130 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +102 −0 htl.py
  3. +12 −0 htl.reg
  4. +14 −0 setup.py
2 .gitignore
@@ -0,0 +1,2 @@
+build
+dist
102 htl.py
@@ -0,0 +1,102 @@
+#! /usr/bin/env python
+
+"""
+Usage: htl.py [options]
+
+Launch a HTA URL
+
+Options:
+ --version show program's version number and exit
+ -h, --help show this help message and exit
+ -p PATH, --path=PATH path to launch
+ -t TITLE, --title=TITLE title of hta
+ -i ICON, --icon=ICON icon of hta
+ -q QUERY, --query=QUERY querystring
+"""
+
+import sys, tempfile, shutil, os
+
+from string import Template
+from optparse import OptionParser
+
+options = {}
+DEFAULTS = {
+ 'title': 'HTA',
+ 'icon': 'green.ico'
+}
+
+def main():
+
+ parser = OptionParser(usage="%prog [options]", version="0.1", description="launch a hta process")
+ parser.add_option('-p', '--path', dest='path', help='path to launch', action="store")
+ parser.add_option('-t', '--title', dest='title', help='title of hta', action="store")
+ parser.add_option('-i', '--icon', dest='icon', help='icon of hta', action="store")
+ parser.add_option('-q', '--query', dest='query', help='query string', action="store")
+ parser.set_defaults(**DEFAULTS)
+ (option_obj, args) = parser.parse_args()
+
+ options['path'] = option_obj.path
+ options['title'] = option_obj.title
+ options['icon'] = option_obj.icon
+ options['query'] = option_obj.query
+
+ if options['path']:
+ path = options['path']
+
+ params = {
+ 'name' : options['title'],
+ 'graphic' : options['icon'],
+ 'url' : options['path']
+ }
+
+ elif options['query']:
+ import urlparse, cgi
+
+ path = options['query'].replace('hta', 'http')
+ qs = cgi.parse_qs(urlparse.urlsplit(path).query)
+
+ try:
+ title = qs['title'][0]
+ except KeyError:
+ title = DEFAULTS['title']
+
+ try:
+ icon = qs['icon'][0]
+ except KeyError:
+ icon = DEFAULTS['icon']
+
+ params = {
+ 'name' : title,
+ 'graphic' : icon,
+ 'url' : path
+ }
+
+ try:
+ temp, path = tempfile.mkstemp(suffix='.hta')
+
+ template = Template("""
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+ <head>
+ <hta:application id='smartmain' sysMenu='yes' applicationName='${name}'
+ scroll='no' windowstate='maximize' maximizeButton='yes'
+ singleInstance='no' caption='yes' border='thick' borderStyle='raised'
+ icon="http://tpscope/gg5052661/icons/${graphic}"
+ navigable='yes'>
+ <title>${name}</title>
+ </head>
+ <frameset>
+ <frame scrolling='yes' application='yes' trusted='yes' src='${url}'></frame>
+ </frameset>
+</html>
+ """)
+
+ os.write(temp, template.substitute(params))
+
+ finally:
+ os.close(temp)
+
+ os.system(path)
+
+if __name__=="__main__":
+ main()
12 htl.reg
@@ -0,0 +1,12 @@
+REGEDIT4
+
+[HKEY_CLASSES_ROOT\hta]
+@="URL:hta Protocol"
+"URL Protocol"=""
+
+[HKEY_CLASSES_ROOT\hta\shell]
+
+[HKEY_CLASSES_ROOT\hta\shell\open]
+
+[HKEY_CLASSES_ROOT\hta\shell\open\command]
+@="\"C:\\gavin\\stuff\\htl.exe\" \"-q %1\""
14 setup.py
@@ -0,0 +1,14 @@
+from distutils.core import setup
+import py2exe
+
+setup(windows = [{"script":"htl.py"}],
+ name = "Launch HTA",
+ zipfile = None,
+ options = {
+ "py2exe": {
+ "compressed" : 1,
+ "dll_excludes": ["w9xpopen.exe"],
+ "bundle_files": 3
+ }
+ },
+)

0 comments on commit 25c8b97

Please sign in to comment.
Something went wrong with that request. Please try again.