Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 5d53227a23b3dd43afd18c63137204178a88f6e5 @opensas committed Nov 9, 2011
Showing with 237 additions and 0 deletions.
  1. +18 −0 .gitignore
  2. +49 −0 build.xml
  3. +122 −0 commands.py
  4. BIN commands.pyc
  5. +4 −0 conf/dependencies.yml
  6. +5 −0 conf/messages
  7. +8 −0 conf/routes
  8. +31 −0 documentation/manual/home.textile
  9. 0 src/play.plugins
@@ -0,0 +1,18 @@
+# Extracted from https://github.com/ulrich/macaron-factory/blob/master/.gitignore
+# Ignore all dotfiles...
+.*
+# except for .gitignore
+!.gitignore
+
+# Ignore Play! working directory #
+db
+eclipse
+log
+logs
+precompiled
+tmp
+test-result
+eclipse
+server.pid
+
+
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="openshift" default="build" basedir=".">
+
+ <target name="check" unless="play.path">
+ <fail message="Please specify Play framework path using -Dplay.path=/path/to/framework/home" />
+ </target>
+
+ <path id="project.classpath">
+ <pathelement path="${play.path}/framework/classes"/>
+ <fileset dir="${play.path}/framework/lib">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${play.path}/framework">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="lib">
+ <include name="*.jar"/>
+ </fileset>
+ </path>
+
+ <target name="build" depends="compile">
+ <mkdir dir="lib" />
+ <copy todir="tmp/classes">
+ <fileset dir="src">
+ <include name="**/*.properties"/>
+ <include name="**/*.xml"/>
+ <include name="**/play.plugins"/>
+ <include name="**/play.static"/>
+ </fileset>
+ </copy>
+ <jar destfile="lib/play-openshift.jar" basedir="tmp/classes">
+ <manifest>
+ <section name="Play-module">
+ <attribute name="Specification-Title" value="openshift"/>
+ </section>
+ </manifest>
+ </jar>
+ <delete dir="tmp" />
+ </target>
+
+ <target name="compile" depends="check">
+ <mkdir dir="tmp/classes" />
+ <javac srcdir="src" destdir="tmp/classes" target="1.5" debug="true">
+ <classpath refid="project.classpath" />
+ </javac>
+ </target>
+
+</project>
@@ -0,0 +1,122 @@
+import sys
+import subprocess
+from optparse import OptionParser
+
+MODULE = 'openshift'
+
+# Commands that are specific to your module
+COMMANDS = []
+for command in ["hello", "chk", "info"]:
+ COMMANDS.append("openshift:%s" % command)
+ COMMANDS.append("rhc:%s" % command)
+
+class OpenshiftOptionParser(OptionParser):
+ def error(self, msg):
+ pass
+
+def execute(**kargs):
+ command = kargs.get("command")
+ app = kargs.get("app")
+ args = kargs.get("args")
+ env = kargs.get("env")
+
+ command = command[command.index(":")+1:]
+
+ parser = OpenshiftOptionParser()
+ parser.add_option("-a", "--app", dest="app", help="Application name (alphanumeric) (required)")
+ parser.add_option("-l", "--rhlogin", dest="rhlogin", help="Red Hat login (RHN or OpenShift login with OpenShift Express access)")
+ parser.add_option("-p", "--password", dest="password", help="RHLogin password (optional, will prompt)")
+ parser.add_option("-d", "--debug", dest="debug", help="Print Debug info")
+ parser.add_option("", "--timeout", dest="timeout", help="Timeout, in seconds, for connection")
+ options, args = parser.parse_args(args)
+
+ app.check()
+
+ print options
+
+ sys.exit()
+
+ if command == "hello":
+ print "~ Hello"
+
+ if command == "chk":
+ openshift_check()
+
+ if command == "info":
+ openshift_info(options)
+
+# This will be executed before any command (new, run...)
+def before(**kargs):
+ command = kargs.get("command")
+ app = kargs.get("app")
+ args = kargs.get("args")
+ env = kargs.get("env")
+
+
+# This will be executed after any command (new, run...)
+def after(**kargs):
+ command = kargs.get("command")
+ app = kargs.get("app")
+ args = kargs.get("args")
+ env = kargs.get("env")
+
+ if command == "new":
+ pass
+
+def openshift_check():
+ check_git()
+
+def check_git():
+ git_cmd = ["git", "version"]
+ try:
+ result = subprocess.call(git_cmd)
+ if not result == 0:
+ print "~"
+ print "~ Failed to execute git, check that git is installed."
+ print "~"
+ sys.exit(-1)
+
+ except OSError:
+ print "~"
+ print "~ Failed to execute git, check that git is installed."
+ print "~"
+ sys.exit(-1)
+
+
+def openshift_info(options):
+ info_cmd = ["rhc-user-info", "--apps"]
+
+ if options.rhlogin == None:
+ print "~"
+ print "~ You must provide rhlogin parameter."
+ print "~"
+ sys.exit(-1)
+
+ if options.password == None:
+ print "~"
+ print "~ You must provide rhlogin parameter."
+ print "~"
+ sys.exit(-1)
+
+
+ #for item in ["rhlogin", "password", "debug", "timeout"]:
+ # if eval('options.%s' % item) != None:
+ # info_cmd.append("--%s=%s" % (item, eval('options.%s' % item)))
+
+ try:
+
+ print info_cmd
+ result = subprocess.call(info_cmd)
+ if not result == 0:
+ print "~"
+ print "~ Failed to execute rhc-user-info, check that rhc-user-info is installed."
+ print "~"
+ sys.exit(-1)
+
+ except OSError:
+ print "~"
+ print "~ Failed to execute rhc-user-info, check that rhc-user-info is installed."
+ print "~"
+ sys.exit(-1)
+
+
Binary file not shown.
@@ -0,0 +1,4 @@
+self: play -> openshift 0.1
+
+require:
+ - play
@@ -0,0 +1,5 @@
+# Default openshift messages
+# You can specialize this file for each language.
+# For exemple, for french create a messages.fr file
+
+#openshift.name=openshift
@@ -0,0 +1,8 @@
+# This file defines all module routes (Higher priority routes first)
+#
+# import these routes in the main app as :
+# * / module:openshift
+#
+# ~~~~
+
+GET /? Module.index
@@ -0,0 +1,31 @@
+h1. {module name}
+
+p(note). Write your module documentation in this file, possibly linking to other Textile files, and delete these notes when you are finished.
+
+p(note). Start with a clear statement of what the module is and what it is for. Link to any third-party libraries that the module is based on.
+
+p(note). Briefly describe why you might want to use this module in a Play application.
+
+h2. Sample application
+
+p(note). Your module should contain a sample app in the @sample@ directory that demonstrates the module. Describe how to run the demo here.
+
+h2. Getting started
+
+p(note). Describe any installation that is required, beyond adding and resolving the module dependency.
+
+h2. Configuration
+
+p(note). List any configuration options that the module uses, with an @h3.@ heading for each one.
+
+h2. Usage
+
+p(note). Explain how to use the module, and describe any routes, controllers, models or views that the module provides.
+
+h2. Tags
+
+p(note). List any tags the module provides, with an @h3.@ heading for each one. Include the tags’ arguments.
+
+h2. Commands
+
+p(note). List any commands the module provides, with an @h3.@ heading for each one. Include the commands’ options.
No changes.

0 comments on commit 5d53227

Please sign in to comment.