~ubuntu-branches/ubuntu/natty/quickly/natty

« back to all changes in this revision

Viewing changes to data/templates/ubuntu-project/create.py

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-03-29 19:00:48 UTC
  • mfrom: (8.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100329190048-olhobq492x3xnztz
Tags: 0.3.90-0ubuntu1
* New release:
  Quickly core:
  - check now that --template has one argument
  - -- enables to give options to templates (unknown options and arguments
    are still given to templates but -- specify explicity what to give to
    templates commands like -h, --version...)
  - check and enable recreation of the credential if user deletes it on
    Launchpad
  - Use realpath so that we can symlink to the binary in trunk.
    (Jonathan Lange)
  - project_path_not_found is raised when data_path_not_found should be
    (originated from Philip Peitsch's patch). (LP: #497688)
  - importing command in one template from another template is now possible
    support as well "all" keyword to import all commands from a template
    into another one (take care of overridden commands too)
    (LP: #452306, #487301)
  - add an apport hook to get installed templates (LP: #411127)
  - enable option completion for templates
  - handle now version upgrade, launching script for templates and handling
    versionning on them
  - change getstarted wording (LP: #486180) - Grant
  - Quickly ship now "version" tag instead of "format" tag
  - add some templatetools to check X display
  - if a commands exit with 4, do not show "ERROR:" (case of wrong command
    usage, for instance)
  - Rewrote importing module in both bin/quickly and ubuntu-project binary
  - Add get_camel_case_name() and get_sentence_name() to templatetools
  - Refactor some code in pre_create hook()
  - Now dashes and spaces support in project name! Dealing with python and
    packaging issues for you. (LP: #493130)
  - Provide Quickly API (LP: #426480)
  - Fix some issues in the man page
  ubuntu-application Template:
  - Enabling upload to team or user ppa, as well as any ppa.
    Use --ppa ppaname or --ppa team/ppaname
    .quickly file can be used as well with ppa = ppaname or
    ppa = team/ppaname (LP: #470192)
    ppa completion is also available
  - Change BSD header by full license
  - Add MIT license
  - Fixes an error when launchpad display name contains unicode character
    (Petar Vasić)
  - Fix typo in quickly help save (Petar Vasić)
  - Adds logo.png as logo property in about dialog (LP: #478389)
    (Petar Vasić)
  - Remove lp-project-change command and add configure command.
    configure lp-project [project_name] to set/reset lp project binded to
    your Quickly project
    ppa <ppa name> to set a default ppa with your project
  - Fix ~/.selected-editor being ignored (LP: #484730)
  - Fix wrong shell completion when in a template (it wrongly proposed
    all commands followed by templates)
  - Check if we have a X display available before running "run" or launching
    GUI in "create" command.
  - add -- support in quickly run to pass options like --help, --version so
    that Quickly core don't take them.
  - enable preferences save call being called multiple times (Philip Peitsch)
  - Use realpath so that we can symlink to the binary in trunk.
  - Fixed some errors in the tutorial (Brian) (LP: #499356)
  - Fix missing import sys in setup.py (Philip Peitsch) (LP: #499712)
  - rename ubuntu-project to ubuntu-application
  - enhance quickly license (no more Copyright file, only one AUTHORS file)
    personal license needs COPYING file now (and the header will be copied in
    every files). No more # needed in those files too. Some other little
    refactoring too (LP: #469330)
  - autolicence by default on first share/release (with LP info and on GPL-3)
  - change versionning support in ubuntu application: (LP: #476814)
   + quickly share just adds -publicX to current version where X is bumped
     at each "quicky share" execution
   + quickly release remove -publicX (if any) and release with current YY.MM.
     If there is already a release with that version, it will be YY.MM.1, 
     then YY.MM.2
  - add accelerators to menu items (jens persson)
  - set correctly title dialog (Philip Peitsch) (LP: #501999)
  - about dialog box is now fully automated: (LP: #478414)
   + update copyright, authors, license (when licensing)
   + version (when sharing and releasing)
   + homepage (when changing launchpad project: release and configure)
  - add an 'add' command. $ quickly dialog … is now $ quickly add dialog …
    (LP: #438320)
  - enable automatic release and milestone built in LP, releasing and pushing
    upstream tarball (LP: #470344)
  - automatic collect and publish changelog message from commits and save
    messages used during devlopment. (LP: #476572)
  - add i18n to boiler plate (LP: #423529)
  - enable adding manual depdencies to quickly project (LP: #474639)
  - enable configure its own bzr branch and resetting parent branch even once
    already configured (quickly configure bzr <branch-path>)
  - now recommends seahorse-plugins to have a graphical prompt for signing
    package
  - rename quickly glade to quickly design (LP: #528664)
  - create command is now more flexible and enable people to inherit from
    other template more easily
  - add translation domain to gtkbuilder and fix some items that shouldn't
    been translatable (Łukasz Jernaś)
  - add apport and launchpadintegration to new and existing project once
    bounded to LP (Philip Peitsch)
  - fix spelling mistake "connexion" (Łukasz Jernaś) (LP: #532667)
  - the ubuntu-application tutorial is now internationalized and use docbook
    format. Translators, it's yours! (Shane Fagan) (LP: #525168)
  - package/share/release are now more quiet and only print something on error
    warning as a summary as with unfound packages, and so on (LP: #482915)
  - new algorithm to select good email automatically. Try to get the preferred
    email and update the AUTHOR file with it.
  - test GPG key and create one automatically if none is available. The
    corresponding public key availabity in launchpad is also checked.
    (LP: #427730, #408993)
  - add devscripts as a dependency (bug #465833), will fix all the depends
    mess later
  - bump python-distutils-extra (>= 2.18bzr1)
  ubuntu-cli Template:
  - first release using import command feature (no command written into the
    template itself). This is a basic ubuntu CLI application
  ubuntu-pygame Template:
  - first release using import command feature. python-pygame added as a
    depends
* debian/control:
  - renamed and separate in multiple packages to get a -common used with
    Quickly widgets (LP: #519633)
  - suggests python-quickly-widgets

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
# -*- coding: utf-8 -*-
3
 
# Copyright 2009 Canonical Ltd.
4
 
# Author 2009 Didier Roche
5
 
#
6
 
# This file is part of Quickly ubuntu-project-template
7
 
#
8
 
#This program is free software: you can redistribute it and/or modify it 
9
 
#under the terms of the GNU General Public License version 3, as published 
10
 
#by the Free Software Foundation.
11
 
 
12
 
#This program is distributed in the hope that it will be useful, but 
13
 
#WITHOUT ANY WARRANTY; without even the implied warranties of 
14
 
#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
15
 
#PURPOSE.  See the GNU General Public License for more details.
16
 
 
17
 
#You should have received a copy of the GNU General Public License along 
18
 
#with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 
 
20
 
import sys
21
 
import os
22
 
import shutil
23
 
import subprocess
24
 
 
25
 
from quickly import templatetools
26
 
from internal import quicklyutils
27
 
 
28
 
import gettext
29
 
from gettext import gettext as _
30
 
# set domain text
31
 
gettext.textdomain('quickly')
32
 
 
33
 
 
34
 
 
35
 
def help():
36
 
    print _("""Usage:
37
 
$ quickly create ubuntu-project path/to/project_name
38
 
 
39
 
where "project_name" is one or more words separated by an underscore and
40
 
path/to can be any existing path.
41
 
 
42
 
This will create and run a new project, including Python code, 
43
 
Glade files, and packaging files to make the project work. After
44
 
creating the project, get started by:
45
 
 
46
 
1. Changing your working directory to the new project:
47
 
$ cd path/to/project_name
48
 
 
49
 
2. Edit the UI with Glade:
50
 
$ quickly glade
51
 
 
52
 
3. Edit the Python code:
53
 
$ quickly edit
54
 
""")
55
 
templatetools.handle_additional_parameters(sys.argv, help)
56
 
 
57
 
# get origin path
58
 
pathname = os.path.dirname(__file__)
59
 
abs_path = os.path.abspath(pathname) + "/"
60
 
 
61
 
 
62
 
# get the name of the project
63
 
if len(sys.argv) < 2:
64
 
    print _("""
65
 
ERROR: project name not defined. Usage is project_name""")
66
 
    sys.exit(1)
67
 
 
68
 
os.chdir(sys.argv[1])
69
 
 
70
 
path_and_project = sys.argv[1].split('/')
71
 
project_name = path_and_project[-1]
72
 
 
73
 
# check that project name follow quickly rules and reformat it.
74
 
project_name = templatetools.quickly_name(project_name)
75
 
 
76
 
# create additional directories
77
 
data_dir = "data"
78
 
print _("Creating project directory %s") % data_dir
79
 
os.mkdir(data_dir)
80
 
print _("Directory %s created\n") % data_dir
81
 
 
82
 
python_dir = project_name
83
 
print _("Creating project directory %s") % python_dir
84
 
os.mkdir(python_dir)
85
 
print _("Directory %s created\n") % python_dir
86
 
 
87
 
bin_dir = "bin"
88
 
print _("Creating project directory %s") % bin_dir
89
 
os.mkdir(bin_dir)
90
 
print _("Directory %s created\n") % bin_dir
91
 
 
92
 
sentence_name, camel_case_name = quicklyutils.conventional_names(project_name)
93
 
 
94
 
# copy files
95
 
template_ui_dir = abs_path + "data/ui/"
96
 
target_ui_dir = "data/ui"
97
 
os.mkdir(target_ui_dir)
98
 
 
99
 
substitutions = (("project_name",project_name),
100
 
            ("camel_case_name",camel_case_name),
101
 
            ("sentence_name",sentence_name),)
102
 
 
103
 
 
104
 
# create the files for glade to use
105
 
quicklyutils.file_from_template(template_ui_dir, "camel_case_nameWindow.ui", target_ui_dir, substitutions)
106
 
quicklyutils.file_from_template(template_ui_dir, "project_name_window.xml", target_ui_dir, substitutions)
107
 
quicklyutils.file_from_template(template_ui_dir, "Aboutcamel_case_nameDialog.ui", target_ui_dir, substitutions)
108
 
quicklyutils.file_from_template(template_ui_dir, "about_project_name_dialog.xml", target_ui_dir, substitutions)
109
 
quicklyutils.file_from_template(template_ui_dir, "Preferencescamel_case_nameDialog.ui", target_ui_dir, substitutions)
110
 
quicklyutils.file_from_template(template_ui_dir, "preferences_project_name_dialog.xml", target_ui_dir, substitutions)
111
 
 
112
 
# create the python directory and files
113
 
template_python_dir = abs_path + "python/"
114
 
target_python_dir = project_name
115
 
quicklyutils.file_from_template(template_python_dir, "Aboutcamel_case_nameDialog.py", target_python_dir, substitutions)
116
 
quicklyutils.file_from_template(template_python_dir, "Preferencescamel_case_nameDialog.py", target_python_dir, substitutions)
117
 
quicklyutils.file_from_template(template_python_dir, "project_nameconfig.py", target_python_dir, substitutions)
118
 
 
119
 
# copy the files needed for packaging
120
 
quicklyutils.file_from_template(abs_path, "project_root/setup.py", ".", substitutions)
121
 
quicklyutils.file_from_template(template_python_dir, "__init__.py", target_python_dir)
122
 
 
123
 
# create the media directory, and copy them
124
 
template_media_dir = abs_path + "data/media"
125
 
target_media_dir = "data/media"
126
 
shutil.copytree(template_media_dir,target_media_dir)
127
 
 
128
 
# copy the desktop file
129
 
quicklyutils.file_from_template(abs_path ,"project_root/project_name.desktop.in",".", substitutions)
130
 
 
131
 
# copy the executable file, set the mode to executable
132
 
quicklyutils.file_from_template(abs_path ,"bin/project_name","bin", substitutions)
133
 
os.chmod("bin/" + project_name, 0755)
134
 
 
135
 
# copy the licence file
136
 
quicklyutils.file_from_template(abs_path ,"project_root/Copyright",".", substitutions)
137
 
 
138
 
# add it to revision control
139
 
print _("Creating bzr repository and commiting")
140
 
subprocess.call(["bzr", "init"])
141
 
subprocess.call(["bzr", "add"])
142
 
subprocess.call(["bzr", "commit", "-m", "Initial project creation with Quickly!"])
143
 
 
144
 
# run the new application
145
 
print _("Launching your newly created project!")
146
 
subprocess.call(['./' + project_name], cwd='bin/')
147
 
 
148
 
print _("Congrats, your new project is setup! cd %s/ to start hacking. Then '$ quickly tutorial' for quickly ubuntu-template tutorial and reference") % os.getcwd()
149
 
 
150
 
sys.exit(0)
151