/usr/share/quickly/templates/ubuntu-flash-game/create.py is in quickly-ubuntu-template 12.08.1-0ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | #!/usr/bin/python
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2009 Didier Roche
#
# This file is part of Quickly ubuntu-application template
#
#This program is free software: you can redistribute it and/or modify it
#under the terms of the GNU General Public License version 3, as published
#by the Free Software Foundation.
#This program is distributed in the hope that it will be useful, but
#WITHOUT ANY WARRANTY; without even the implied warranties of
#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
#PURPOSE. See the GNU General Public License for more details.
#You should have received a copy of the GNU General Public License along
#with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import os
import shutil
import subprocess
from quickly import templatetools
from internal import quicklyutils, SWF
import gettext
from gettext import gettext as _
# set domain text
gettext.textdomain('quickly')
def help():
print _("""Usage:
$ quickly create ubuntu-flash-game path/to/project_name path/to/myflashgame.swf
where 'project_name' is one or more words separated by an underscore and
path/to can be any existing path.
This will create a new project which runs your existing SWF, myflashgame.swf,
on the Ubuntu desktop, and makes it ready to be packaged and distributed in
the Ubuntu Software Centre.
After creating the project, you'll want to specify the title of your game
and the size of the window:
1. Changing your working directory to the new project:
$ cd path/to/project_name
2. Edit the code and specify the title and window size:
$ quickly edit
""")
templatetools.handle_additional_parameters(sys.argv, help)
# get the name of the project
if len(sys.argv) < 2:
print _("""Project name not defined.\nUsage:\n$ quickly create ubuntu-flash-game project_name myflashgame.swf""")
sys.exit(4)
if len(sys.argv) < 3:
print _("""Flash SWF file not defined.\nUsage:\n$ quickly create ubuntu-flash-game project_name myflashgame.swf""")
sys.exit(5)
path_and_project = sys.argv[1].split('/')
project_name = path_and_project[-1]
swf = os.path.realpath(sys.argv[2])
if not os.path.exists(swf):
print _("""Flash SWF file %s not found.\nUsage:\n$ quickly create ubuntu-flash-game project_name myflashgame.swf""" % swf)
sys.exit(6)
# check that project name follow quickly rules and reformat it.
try:
project_name = templatetools.quickly_name(project_name)
except templatetools.bad_project_name, e:
print(e)
sys.exit(1)
os.chdir(project_name)
# Calculate the SWF's dimensions
try:
width, height = SWF.dimensions(swf)
except SWF.SWFNotASWF:
print "File '%s' does not seem to be a SWF. Terminating."
sys.exit(7)
except SWF.SWFNoDimensions:
print "(Could not read size from SWF file; defaulting to 640x480. You should edit bin/%s with the correct size.)" % project_name
width, height = (640, 480)
substitutions = [("swf_height",str(height)),
("swf_width",str(width))]
templatetools.copy_dirs_from_template(extra_substitutions = substitutions)
# set the mode to executable for executable file
exec_file = os.path.join('bin', project_name)
try:
os.chmod(exec_file, 0755)
except:
pass
# Copy the specified SWF file into the project
shutil.copyfile(swf, os.path.join("data", "game.swf"))
# We require a specific version of the ubuntu-application template, so
# edit the project's .quickly file to specify it.
#WORKAROUND
fp = open(".quickly", "a")
fp.write("\nversion_ubuntu-application = 0.4\n")
fp.close()
# add it to revision control
print _("Creating bzr repository and commiting")
bzr_instance = subprocess.Popen(["bzr", "init"], stdout=subprocess.PIPE)
bzr_instance.wait()
bzr_instance = subprocess.Popen(["bzr", "add"], stdout=subprocess.PIPE)
bzr_instance.wait()
subprocess.Popen(["bzr", "commit", "-m", "Initial project creation with Quickly!"], stderr=subprocess.PIPE)
# run the new application if X display
if templatetools.is_X_display() and os.path.isfile(exec_file):
print _("Launching your newly created project!")
subprocess.call(['./' + project_name], cwd='bin/')
print _("Congratulations, your new project is set up! cd %s/ to edit the details.") % os.getcwd()
sys.exit(0)
|