aboutsummaryrefslogtreecommitdiffstats
path: root/Troublegun.app/Contents
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2016-02-02 11:47:15 +0200
committerFilipp Lepalaan <filipp@mac.com>2016-02-02 11:47:15 +0200
commit07edebe011f3a17d0113e4f34b537e9e3e725a2a (patch)
treecda107656b2fe6d204bb15fcc70cc67616541425 /Troublegun.app/Contents
downloadTroublegun-07edebe011f3a17d0113e4f34b537e9e3e725a2a.tar.gz
Troublegun-07edebe011f3a17d0113e4f34b537e9e3e725a2a.tar.bz2
Troublegun-07edebe011f3a17d0113e4f34b537e9e3e725a2a.zip
Initial commit
Diffstat (limited to 'Troublegun.app/Contents')
-rw-r--r--Troublegun.app/Contents/Info.plist48
-rwxr-xr-xTroublegun.app/Contents/MacOS/appletbin0 -> 25028 bytes
-rw-r--r--Troublegun.app/Contents/PkgInfo1
-rw-r--r--Troublegun.app/Contents/Resources/Scripts/main.scptbin0 -> 584 bytes
-rw-r--r--Troublegun.app/Contents/Resources/applet.icnsbin0 -> 71867 bytes
-rw-r--r--Troublegun.app/Contents/Resources/applet.rsrcbin0 -> 362 bytes
-rw-r--r--Troublegun.app/Contents/Resources/config.ini7
-rw-r--r--Troublegun.app/Contents/Resources/description.rtfd/TXT.rtf4
-rw-r--r--Troublegun.app/Contents/Resources/entourage.scpt6
-rw-r--r--Troublegun.app/Contents/Resources/gethelper.sh1
-rw-r--r--Troublegun.app/Contents/Resources/mail.scpt10
-rwxr-xr-xTroublegun.app/Contents/Resources/main.py62
12 files changed, 139 insertions, 0 deletions
diff --git a/Troublegun.app/Contents/Info.plist b/Troublegun.app/Contents/Info.plist
new file mode 100644
index 0000000..cab3e74
--- /dev/null
+++ b/Troublegun.app/Contents/Info.plist
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleAllowMixedLocalizations</key>
+ <true/>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>applet</string>
+ <key>CFBundleIconFile</key>
+ <string>applet</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.apple.ScriptEditor.id.Troublegun</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>Troublegun</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>aplt</string>
+ <key>LSMinimumSystemVersionByArchitecture</key>
+ <dict>
+ <key>x86_64</key>
+ <string>10.6</string>
+ </dict>
+ <key>LSRequiresCarbon</key>
+ <true/>
+ <key>WindowState</key>
+ <dict>
+ <key>dividerCollapsed</key>
+ <false/>
+ <key>eventLogLevel</key>
+ <integer>-1</integer>
+ <key>name</key>
+ <string>ScriptWindowState</string>
+ <key>positionOfDivider</key>
+ <real>333</real>
+ <key>savedFrame</key>
+ <string>156 168 602 597 0 0 1440 878 </string>
+ <key>selectedTabView</key>
+ <string>result</string>
+ </dict>
+</dict>
+</plist>
diff --git a/Troublegun.app/Contents/MacOS/applet b/Troublegun.app/Contents/MacOS/applet
new file mode 100755
index 0000000..4f7d67b
--- /dev/null
+++ b/Troublegun.app/Contents/MacOS/applet
Binary files differ
diff --git a/Troublegun.app/Contents/PkgInfo b/Troublegun.app/Contents/PkgInfo
new file mode 100644
index 0000000..3253614
--- /dev/null
+++ b/Troublegun.app/Contents/PkgInfo
@@ -0,0 +1 @@
+APPLaplt \ No newline at end of file
diff --git a/Troublegun.app/Contents/Resources/Scripts/main.scpt b/Troublegun.app/Contents/Resources/Scripts/main.scpt
new file mode 100644
index 0000000..38b8ccd
--- /dev/null
+++ b/Troublegun.app/Contents/Resources/Scripts/main.scpt
Binary files differ
diff --git a/Troublegun.app/Contents/Resources/applet.icns b/Troublegun.app/Contents/Resources/applet.icns
new file mode 100644
index 0000000..0cdd170
--- /dev/null
+++ b/Troublegun.app/Contents/Resources/applet.icns
Binary files differ
diff --git a/Troublegun.app/Contents/Resources/applet.rsrc b/Troublegun.app/Contents/Resources/applet.rsrc
new file mode 100644
index 0000000..a3d8348
--- /dev/null
+++ b/Troublegun.app/Contents/Resources/applet.rsrc
Binary files differ
diff --git a/Troublegun.app/Contents/Resources/config.ini b/Troublegun.app/Contents/Resources/config.ini
new file mode 100644
index 0000000..ccc45a5
--- /dev/null
+++ b/Troublegun.app/Contents/Resources/config.ini
@@ -0,0 +1,7 @@
+[message]
+name: Our IT guy
+address: you@example.com
+subject: Problem Report
+message: Application:
+Problem:
+attachments: screencapture
diff --git a/Troublegun.app/Contents/Resources/description.rtfd/TXT.rtf b/Troublegun.app/Contents/Resources/description.rtfd/TXT.rtf
new file mode 100644
index 0000000..116a631
--- /dev/null
+++ b/Troublegun.app/Contents/Resources/description.rtfd/TXT.rtf
@@ -0,0 +1,4 @@
+{\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf210
+{\fonttbl}
+{\colortbl;\red255\green255\blue255;}
+} \ No newline at end of file
diff --git a/Troublegun.app/Contents/Resources/entourage.scpt b/Troublegun.app/Contents/Resources/entourage.scpt
new file mode 100644
index 0000000..b893a61
--- /dev/null
+++ b/Troublegun.app/Contents/Resources/entourage.scpt
@@ -0,0 +1,6 @@
+tell application "Microsoft Entourage"
+ set theRecipients to {{address:{display name:"%@", address:"%@"}, recipient type:to recipient}}
+ set theMessage to make new outgoing message with properties {recipient:theRecipients, subject:"%@", attachment:{file:(POSIX file "%@")}}
+ open theMessage
+ activate
+end tell
diff --git a/Troublegun.app/Contents/Resources/gethelper.sh b/Troublegun.app/Contents/Resources/gethelper.sh
new file mode 100644
index 0000000..2071ec7
--- /dev/null
+++ b/Troublegun.app/Contents/Resources/gethelper.sh
@@ -0,0 +1 @@
+defaults read com.apple.launchservices LSHandlers | grep -B 1 mailto | grep RoleAll | awk 'IFS="=" { print $3; }'
diff --git a/Troublegun.app/Contents/Resources/mail.scpt b/Troublegun.app/Contents/Resources/mail.scpt
new file mode 100644
index 0000000..ee447a9
--- /dev/null
+++ b/Troublegun.app/Contents/Resources/mail.scpt
@@ -0,0 +1,10 @@
+tell application "Mail"
+ set theMessage to make new outgoing message with properties {visible:true, subject:"$subject", content:"$message"}
+ tell theMessage
+ make new to recipient at end of to recipients with properties {name:"$name", address:"$address"}
+ end tell
+ tell content of theMessage
+ make new attachment with properties {file name:"$filename"}
+ end tell
+ activate
+end tell
diff --git a/Troublegun.app/Contents/Resources/main.py b/Troublegun.app/Contents/Resources/main.py
new file mode 100755
index 0000000..76cbbb0
--- /dev/null
+++ b/Troublegun.app/Contents/Resources/main.py
@@ -0,0 +1,62 @@
+#! /usr/bin/env python
+
+import os
+import subprocess
+import ConfigParser
+from string import Template
+from tempfile import NamedTemporaryFile
+
+
+def getresource(res):
+ from os.path import realpath, join, dirname
+ return join(dirname(realpath(__file__)), res)
+
+def getconfig():
+ config = dict()
+ ini = ConfigParser.ConfigParser()
+ inipath = getresource('config.ini')
+ ini.read(inipath)
+ for i in ini.options('message'):
+ config[i] = ini.get('message', i)
+
+ return config
+
+def gethelper():
+ helper = subprocess.check_output(['sh', getresource('gethelper.sh')])
+ return helper.strip()
+
+def screencapture():
+ f = NamedTemporaryFile(delete=False, suffix=".png")
+ f.close()
+ subprocess.call(['screencapture', '-C', f.name])
+ return f.name
+
+def makemail(config):
+ helper = gethelper()
+
+ if "com.apple.mail" in helper:
+ scpt = file(getresource("mail.scpt"), "r")
+ elif "entourage" in helper:
+ scpt = file(getresource("entourage.scpt"), "r")
+ else:
+ raise Exception("%s is not a supported mail app" % helper)
+
+ compiled_scpt = Template.substitute(Template(scpt.read()), config)
+ exe = NamedTemporaryFile(delete=False, suffix=".scpt")
+ exe.write(compiled_scpt)
+ exe.close()
+ return exe.name
+
+def main():
+ config = getconfig()
+
+ if 'screencapture' in config.get('attachments'):
+ config['filename'] = screencapture()
+
+ exe = makemail(config)
+ subprocess.call(['osascript', exe])
+ os.unlink(exe)
+
+
+if __name__ == '__main__':
+ main()