Permalink
Browse files

Prepping to add glandslide; revamped ec2launch to install tarball

  • Loading branch information...
1 parent 97d9158 commit 1d351a0af07ef57923e0662fd515b0cec64aa559 @mitotic committed Sep 25, 2012
Showing with 103 additions and 17 deletions.
  1. +1 −0 COPYING
  2. +2 −1 MANIFEST.in
  3. +13 −1 README.rst
  4. +1 −1 graphterm/about.py
  5. +61 −8 graphterm/bin/ec2launch
  6. +4 −2 graphterm/bin/giframe
  7. +9 −1 graphterm/www/graphterm.css
  8. +10 −2 graphterm/www/graphterm.js
  9. +1 −1 graphterm/www/index.html
  10. +1 −0 setup.py
View
@@ -9,4 +9,5 @@ as indicated in the respective files. These include:
AjaxTerm: Public Domain
CKEditor: MPL
jQuery and plugins: MIT-type licenses
+ Landslide: Apache
Tango icons: Public Domain
View
@@ -1,5 +1,6 @@
include COPYING LICENSE.txt *.rst *.html
-recursive-include graphterm *.py *.js *.css *.html *.rst *.txt *.gif *.jpg *.png
+recursive-include graphterm *.py *.js *.css *.html *.md *.rst *.txt *.gif *.jpg *.png
+recursive-include docs *.html *.md *.rst
graft graphterm/bin
graft graphterm/certs
global-exclude *~ *.pyc test*
View
@@ -168,6 +168,8 @@ for other commands, which include:
``gimage [-f] [filenames]`` To view images inline, or as a
fullpage slideshow (with ``-f`` option)
+ ``glandslide`` A GraphTerm-aware version of Landslide, a web-based slideshow program
+
``gmatplot.py`` A ``matplotlib`` plotting demo
``yweather [location]`` To view weather forecasts
@@ -357,7 +359,17 @@ with caution to avoid exposing exposing sensitive data.*
Slideshows
---------------------------------------------------------------------------------------
-The ``gimage`` command, which displays images inline, can be used for
+The ``glandslide`` command, which is a slightly modified version of the
+web-based slide slideshow program `Landslide <https://github.com/adamzap/landslide>`_,
+can be used to create a slideshow from Markdown (.md) or reStructured
+Text (.rst) files::
+
+ glandslide -o slides.md | giframe
+
+(The unmodified Landslide program can also be used, with the ``-i``
+option, but remote sharing will not work.)
+
+The ``gimage`` command, which displays images inline, can also be used for
slideshows and simple presentations. Just ``cd`` to a directory
that has the images for a slideshow, and type::
View
@@ -1,4 +1,4 @@
-version = "0.32.0"
+version = "0.32.0+"
min_version = "0.31"
View
@@ -32,6 +32,7 @@ form_parser.add_option("ami", "ami-82fa58eb", help="Instance OS (default: Ubuntu
form_parser.add_option("auth_code", "none", help="User authentication code")
form_parser.add_option("server_secret", "", help="Server secret for host authentication (to connect from anywhere)")
form_parser.add_option("connect_to_gterm", "", help="Full domain name of GraphTerm server to connect to")
+form_parser.add_option("install", "", help="Tar file to install on startup (with optional '; command' suffix)")
form_parser.add_option("pylab", False, help="Install PyLab")
form_parser.add_option("oshell", False, help="Enable OTrace shell")
form_parser.add_option("dry_run", False, help="Dry run")
@@ -64,6 +65,27 @@ if not os.path.exists(ssh_dir):
print >> sys.stderr, "ec2launch: %s directory not found!" % ssh_dir
sys.exit(1)
+install_file, install_cmd, install_basename, install_baseroot, unarch_cmd = "", "", "", "", ""
+if options.install:
+ install_file, sep, install_cmd = options.install.partition(";")
+ if not os.path.isfile(install_file):
+ raise Exception("Install file "+install_file+" not found")
+ install_basename = os.path.basename(install_file)
+ install_baseroot, ext = os.path.splitext(install_basename)
+ if ext == ".gz":
+ install_baseroot, ext = os.path.splitext(install_baseroot)
+ if ext != ".tar":
+ raise Exception("Invalid extension for install file: "+install_file)
+ unarch_cmd = "tar zxf"
+ elif ext == ".tgz":
+ unarch_cmd = "tar zxf"
+ elif ext == ".tar":
+ unarch_cmd = "tar xf"
+ elif ext == ".zip":
+ unarch_cmd = "unzip"
+ else:
+ raise Exception("Invalid extension for install file: "+install_file)
+
GroupRule = collections.namedtuple("GroupRule",
["ip_protocol", "from_port", "to_port", "cidr_ip", "src_group_name"])
@@ -80,6 +102,7 @@ SecurityGroups = [
GroupRule("tcp", "80", "80", "0.0.0.0/0", None),
GroupRule("tcp", "8888", "8888", "0.0.0.0/0", None),
GroupRule("tcp", "8899", "8899", "0.0.0.0/0", None if options.server_secret else HostGroupName),
+ GroupRule("tcp", "8900", "8900", "0.0.0.0/0", None),
],
)
]
@@ -91,10 +114,12 @@ startup_commands = ["#!/bin/bash",
"apt-get update && apt-get upgrade -y",
"apt-get install -y python-setuptools",
"easy_install tornado",
-"easy_install graphterm",
-"gterm_setup",
]
+if options.auth_code.strip() or options.connect_to_gterm:
+ startup_commands += ["easy_install graphterm",
+ "gterm_setup"]
+
if options.pylab:
startup_commands += ["apt-get install -y python-numpy python-scipy python-matplotlib"]
@@ -104,18 +129,31 @@ if options.oshell:
if options.server_secret:
command_format += ' --server_secret="'+options.server_secret+'"'
+init_command = ""
+fwall_command = ""
if options.connect_to_gterm:
security_groups = [HostGroupName]
server_name, sep, server_domain = options.connect_to_gterm.partition(".")
if not server_domain:
raise Exception("Must specify fully qualified domain name to connect to GraphTerm server")
host_name = instance_name if instance_domain == server_domain else instance_tag
- startup_commands += [(command_format % "gtermhost") + " --server_addr="+ options.connect_to_gterm+" "+host_name]
+ init_command = (command_format % "gtermhost") + " --server_addr="+ options.connect_to_gterm+" "+host_name
+ startup_commands += [ init_command ]
else:
security_groups = [ServerGroupName]
- host_domain = "`hostname`"
- startup_commands += ["iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 8900"]
- startup_commands += [(command_format % "gtermserver") + ' --auth_code="'+options.auth_code+'" --host='+host_domain]
+
+ host_domain = instance_tag if instance_domain else "`curl http://169.254.169.254/latest/meta-data/public-hostname`"
+ fwall_command = "iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 8900"
+ startup_commands += [ fwall_command ]
+ if options.auth_code.strip():
+ init_command = (command_format % "gtermserver") + ' --auth_code="'+options.auth_code+'" --host='+host_domain
+ startup_commands += [ init_command ]
+
+if init_command or fwall_command:
+ startup_commands += [ "echo '"+init_command+"' > /etc/init.d/graphterm",
+ "echo '"+fwall_command+"' > /etc/init.d/graphterm",
+ "chmod +x /etc/init.d/graphterm",
+ "update-rc.d graphterm defaults"]
startup_commands += ["sudo -u "+gterm_user+" -i touch ~" + gterm_user + "/" + setup_file]
@@ -256,15 +294,30 @@ ssh_cmd_args = ["ssh", "-i", os.path.expanduser("~/.ssh/ec2key.pem"),
"-o", "StrictHostKeyChecking=no", gterm_user+"@"+public_dns_name]
wait_cmd = "while [ ! -f "+setup_file+" ]; do sleep 1; done"
-
if nameservers:
print >> sys.stderr, "***NOTE*** Please add the following nameservers for domain "+instance_domain
print >> sys.stderr, " ", nameservers
print >> sys.stderr, ""
print >> sys.stderr, "Waiting for remote setup to complete..."
time.sleep(30)
-out, err = gtermapi.command_output(ssh_cmd_args + [wait_cmd], timeout=360)
+
+if install_file:
+ scp_cmd_args = ["scp", "-i", os.path.expanduser("~/.ssh/ec2key.pem"),
+ "-o", "StrictHostKeyChecking=no", install_file, gterm_user+"@"+public_dns_name+":"]
+ print >> sys.stderr, " ".join(scp_cmd_args)
+ out, err = gtermapi.command_output(scp_cmd_args, timeout=60)
+ if out:
+ print out
+ if err:
+ print err
+ wait_cmd += "; "+unarch_cmd+" "+install_basename+"; cd "+install_baseroot+"; sudo python setup.py install"
+ if install_cmd:
+ wait_cmd += "; "+install_cmd
+
+print >> sys.stderr, " ".join(ssh_cmd_args)
+print >> sys.stderr, wait_cmd
+out, err = gtermapi.command_output(ssh_cmd_args + [wait_cmd], timeout=600)
if out:
print out
View
@@ -7,6 +7,7 @@ giframe: Display file (or HTML from stdin) in inline iframe
import mimetypes
import os
+import random
import sys
import time
@@ -50,9 +51,10 @@ else:
headers = {"opacity": options.opacity}
-IFRAMEFORMAT = '<iframe src="%s" width="100%%" height="'+str(100 if options.nofooter else 95)+'%%"></iframe>'
+frameId = "giframe%09d" % random.randrange(0, 10**9)
+IFRAMEFORMAT = '<iframe id="'+frameId+'" class="gterm-iframe" src="%s" width="100%%" height="'+str(100 if options.nofooter else 95)+'%%"></iframe>'
if not options.nofooter:
- IFRAMEFORMAT += '<pre class="gterm-frame-footer">Click here and type Control-C to exit</pre>'
+ IFRAMEFORMAT = '<span class="gterm-iframeclose gterm-iframeheader">&#215;</span><p>' + IFRAMEFORMAT
gtermapi.write_html(IFRAMEFORMAT % iframe_url, display="fullscreen", add_headers=headers)
@@ -378,6 +378,14 @@ input.gterm-input-arg[type=text] {
padding-bottom: 1.0em;
}
+.gterm-iframe {
+ border-style: none;
+}
+
+.gterm-iframe:not(.noheader) {
+ margin-top: 1em;
+}
+
/* Popup styles */
.gterm-popupmask {
position: absolute;
@@ -409,7 +417,7 @@ input.gterm-input-arg[type=text] {
-box-shadow: 0 0 10px rgba(0,0,0,.4);
}
-span.gterm-popupclose {
+span.gterm-iframeclose, span.gterm-popupclose {
position: absolute;
top: 0px;
right: 5px;
View
@@ -929,7 +929,7 @@ GTWebSocket.prototype.onmessage = function(evt) {
$(pageletSelector+' td .gterm-link').bindclick(gtermPageletClickHandler);
$(pageletSelector+' td img').bind("dragstart", function(evt) {evt.preventDefault();});
$(pageletSelector+' .gterm-blockseqlink').bindclick(gtermLinkClickHandler);
-
+ $(pageletSelector+' .gterm-iframeclose').bindclick(gtermInterruptHandler);
GTDropBindings($(pageletSelector+' .droppable'));
} catch(err) {
console.log("GTWebSocket.onmessage: Pagelet ERROR: ", err);
@@ -1554,6 +1554,11 @@ function gtermClickPaste(text, file_url, options) {
SplitScreen("paste");
}
+function gtermInterruptHandler(event) {
+ if (gWebSocket && gWebSocket.terminal)
+ gWebSocket.term_input(String.fromCharCode(3));
+}
+
function gtermLinkClickHandler(event) {
var contextMenu = gControlActive;
GTReceivedUserInput("click");
@@ -2390,7 +2395,10 @@ GTFrameDispatcher.prototype.open = function(frameController, frameObj) {
if (frameController && "open" in frameController && this.frameProps && this.frameProps.id == frameId) {
frameController.open(this.frameProps);
}
- $(".gterm-frame-footer").hide();
+ if (!gMobileDisplay) {
+ $("#"+frameId).addClass("noheader");
+ $(".gterm-iframeheader").hide();
+ }
$("#"+frameId).focus();
}
View
@@ -185,7 +185,7 @@ <h3 class="gtermsplashalt">GraphTerm was developed as part of the Mindmeldr proj
</div> <!-- gtermsplash -->
<!-- ACE/CK editor -->
-<iframe id="gterm-editframe" src="" width="100%" height="100%"></iframe>
+<iframe id="gterm-editframe" class="gterm-iframe" src="" width="100%" height="100%"></iframe>
<!-- popups -->
<div id="gterm-popupmask" class="gterm-popupmask"></div>
View
@@ -33,6 +33,7 @@ def run(self):
"gtermhost = graphterm.gtermhost:main",
"gterm_setup = graphterm.gterm_setup:main",
"gotrace = graphterm.gotrace:main",
+ "glandslide = graphterm.bin.landslide.main:main",
]},
install_requires=requires,
include_package_data=True,

0 comments on commit 1d351a0

Please sign in to comment.