Skip to content

Commit 177bc6a

Browse files
committed
- Improved build and upload scripts
- Improved actions documentation - Bump the version up to 0.6.4
1 parent 586adbf commit 177bc6a

26 files changed

+242
-82
lines changed

build_dist.py

Lines changed: 115 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,123 @@
2323
import os
2424
import os.path
2525
import subprocess
26-
27-
upload = False
28-
2926
from pkg_resources import resource_filename
30-
setup_path = os.path.abspath(resource_filename(__name__, "setup.py"))
27+
import googlecode_upload
28+
3129

32-
commands = []
33-
commands += ["egg_info", "--tag-build=.dev", "-r"]
34-
commands += ["sdist"]
35-
commands += ["bdist_wininst"]
36-
#commands += ["bdist_msi"]
37-
commands += ["bdist_egg"]
30+
#---------------------------------------------------------------------------
31+
# Functions for running setup.py and building packages.
3832

39-
if upload:
40-
# Make sure HOME is defined; required for .pypirc use.
33+
def build_commands(commands, directory, setup_path):
34+
# Make sure HOME is defined; required for .pypirc use
4135
if "HOME" not in os.environ:
4236
os.putenv("HOME", os.path.expanduser("~"))
43-
commands.insert(3, "register")
44-
commands += ["upload", "--show-response"]
45-
# commands += ["upload_gcode", "--src"]
46-
# commands += ["upload_gcode", "--windows"]
47-
48-
arguments = [sys.executable, setup_path] + commands
49-
os.chdir(os.path.dirname(setup_path))
50-
subprocess.call(arguments)
37+
38+
arguments = [sys.executable, setup_path] + commands
39+
os.chdir(directory)
40+
subprocess.call(arguments)
41+
42+
43+
def build_distribution_and_upload(directory, setup_path):
44+
# Register and upload to pypi.
45+
commands = [
46+
"egg_info", "--tag-build=.dev", "-r",
47+
"register",
48+
"sdist",
49+
"bdist_wininst",
50+
"bdist_egg",
51+
"upload", "--show-response",
52+
]
53+
build_commands(commands, directory, setup_path)
54+
55+
# Find new packages to upload to Google code.
56+
dist_directory = os.path.join(directory, "dist")
57+
filelist = []
58+
for filename in os.listdir(dist_directory):
59+
path = os.path.join(dist_directory, filename)
60+
modified = os.path.getmtime(path)
61+
filelist.append((modified, path))
62+
filelist = sorted(filelist)
63+
most_recent_path = filelist[-1][1]
64+
print "most recent", most_recent_path
65+
filename = os.path.basename(most_recent_path)
66+
basename, extension = os.path.splitext(filename)
67+
print "most recent basename", basename
68+
if extension != ".egg":
69+
raise RuntimeError("Most recent package not an egg file: %r"
70+
% most_recent_path)
71+
if not basename.startswith("dragonfly-"):
72+
raise RuntimeError("Most recent package not for dragonfly: %r"
73+
% most_recent_path)
74+
if basename[-6:-3] != "-py":
75+
raise RuntimeError("Most recent package funny name: %r"
76+
% most_recent_path)
77+
basename = basename[:-6]
78+
79+
# Upload to Google code.
80+
upload_gcode(directory, basename)
81+
82+
83+
def build_distribution(directory, setup_path):
84+
commands = [
85+
"egg_info", "--tag-build=.dev", "-r",
86+
"sdist",
87+
"bdist_wininst",
88+
"bdist_egg",
89+
]
90+
build_commands(commands, directory, setup_path)
91+
92+
93+
#---------------------------------------------------------------------------
94+
# Functions for uploading to Google code.
95+
96+
def load_gcode_credentials(path):
97+
namespace = {}
98+
exec open(path, "r").read() in namespace
99+
return namespace["gcode_username"], namespace["gcode_password"]
100+
101+
102+
def upload_gcode_single(path, summary, labels, username, password):
103+
googlecode_upload.upload(
104+
file=path,
105+
project_name="dragonfly",
106+
user_name=username,
107+
password=password,
108+
summary=summary,
109+
labels=labels,
110+
)
111+
112+
113+
def upload_gcode(directory, basename):
114+
credentials_path = os.path.join(directory, "local.txt")
115+
basepath = os.path.join(directory, "dist", basename)
116+
basepath = basepath.replace("_", "-")
117+
username, password = load_gcode_credentials(credentials_path)
118+
upload_gcode_single(
119+
basepath + ".win32.exe",
120+
"Windows installer",
121+
["Featured", "OpSys-Windows", "Type-Installer"],
122+
username, password,
123+
)
124+
upload_gcode_single(
125+
basepath + ".zip",
126+
"Source archive",
127+
["Featured", "OpSys-Windows", "Type-Source"],
128+
username, password,
129+
)
130+
131+
132+
#---------------------------------------------------------------------------
133+
# Main control.
134+
135+
def main():
136+
# Retrieve directory and file location information.
137+
setup_path = os.path.abspath(resource_filename(__name__, "setup.py"))
138+
directory = os.path.dirname(setup_path)
139+
140+
# Build the distribution packages.
141+
build_distribution(directory, setup_path)
142+
143+
144+
if __name__ == "__main__":
145+
main()

build_upload.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# This file is part of Dragonfly.
3+
# (c) Copyright 2007, 2008 by Christo Butcher
4+
# Licensed under the LGPL.
5+
#
6+
# Dragonfly is free software: you can redistribute it and/or modify it
7+
# under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Dragonfly is distributed in the hope that it will be useful, but
12+
# WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
# Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public
17+
# License along with Dragonfly. If not, see
18+
# <http://www.gnu.org/licenses/>.
19+
#
20+
21+
22+
import os.path
23+
from pkg_resources import resource_filename
24+
25+
from build_dist import build_distribution_and_upload
26+
27+
28+
29+
#---------------------------------------------------------------------------
30+
# Main control.
31+
32+
def main():
33+
# Retrieve directory and file location information.
34+
setup_path = os.path.abspath(resource_filename(__name__, "setup.py"))
35+
directory = os.path.dirname(setup_path)
36+
37+
# Build and upload the distribution packages.
38+
build_distribution_and_upload(directory, setup_path)
39+
40+
41+
if __name__ == "__main__":
42+
main()

documentation/actions.txt

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11

2-
Action framework
2+
Actions sub-package
33
============================================================================
44

5-
The Dragonfly library contains an action framework which which
6-
offers easy and flexible interfaces to common actions, such as
7-
emulating keystrokes. These action types have been objectified,
8-
which means that they are first-class Python objects and can be
9-
treated as such.
5+
The Dragonfly library contains an action framework which offers easy and
6+
flexible interfaces to common actions, such as sending keystrokes and
7+
emulating speech recognition. Dragonfly's actions sub-package has various
8+
types of these actions, each consisting of a Python class. There is for
9+
example a :class:`dragonfly.actions.action_key.Key` class for sending
10+
keystrokes and a :class:`dragonfly.actions.action_mimic.Mimic` class for
11+
emulating speech recognition.
12+
13+
Each of these actions is implemented as a Python class and this makes it
14+
easy to work with them. An action can be created (*defined what it will
15+
do*) at one point and executed (*do what it was defined to do*) later.
16+
Actions can be added together with the ``+`` operator to attend them
17+
together, thereby creating series of actions.
1018

1119
Perhaps the most important method of Dragonfly's actions is their
1220
:meth:`dragonfly.actions.action_base.ActionBase.execute` method, which
13-
performs the actual event associated with them.
21+
performs the actual event associated with its action.
1422

1523
Dragonfly's action types are derived from the
1624
:class:`dragonfly.actions.action_base.ActionBase` class. This base class
@@ -21,8 +29,8 @@ multiple actions and to duplicate an action.
2129
Basic examples
2230
----------------------------------------------------------------------------
2331

24-
The code below shows the basic usage of Dragonfly action
25-
objects. They can be created, combined, executed, etc.
32+
The code below shows the basic usage of Dragonfly action objects. They
33+
can be created, combined, executed, etc.
2634

2735
.. code-block:: python
2836

dragonfly/actions/action_waitwindow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class WaitWindow(ActionBase):
5555
substring search used is *not* case sensitive.
5656
5757
If the correct window context is not found within *timeout*
58-
seconds, then this action will raise an :class`ActionError` to
58+
seconds, then this action will raise an :class:`ActionError` to
5959
indicate the timeout.
6060
6161
"""
3.32 KB
Binary file not shown.
-114 Bytes
Binary file not shown.

dragonfly/documentation/_sources/actions.txt

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11

2-
Action framework
2+
Actions sub-package
33
============================================================================
44

5-
The Dragonfly library contains an action framework which which
6-
offers easy and flexible interfaces to common actions, such as
7-
emulating keystrokes. These action types have been objectified,
8-
which means that they are first-class Python objects and can be
9-
treated as such.
5+
The Dragonfly library contains an action framework which offers easy and
6+
flexible interfaces to common actions, such as sending keystrokes and
7+
emulating speech recognition. Dragonfly's actions sub-package has various
8+
types of these actions, each consisting of a Python class. There is for
9+
example a :class:`dragonfly.actions.action_key.Key` class for sending
10+
keystrokes and a :class:`dragonfly.actions.action_mimic.Mimic` class for
11+
emulating speech recognition.
12+
13+
Each of these actions is implemented as a Python class and this makes it
14+
easy to work with them. An action can be created (*defined what it will
15+
do*) at one point and executed (*do what it was defined to do*) later.
16+
Actions can be added together with the ``+`` operator to attend them
17+
together, thereby creating series of actions.
1018

1119
Perhaps the most important method of Dragonfly's actions is their
1220
:meth:`dragonfly.actions.action_base.ActionBase.execute` method, which
13-
performs the actual event associated with them.
21+
performs the actual event associated with its action.
1422

1523
Dragonfly's action types are derived from the
1624
:class:`dragonfly.actions.action_base.ActionBase` class. This base class
@@ -21,8 +29,8 @@ multiple actions and to duplicate an action.
2129
Basic examples
2230
----------------------------------------------------------------------------
2331

24-
The code below shows the basic usage of Dragonfly action
25-
objects. They can be created, combined, executed, etc.
32+
The code below shows the basic usage of Dragonfly action objects. They
33+
can be created, combined, executed, etc.
2634

2735
.. code-block:: python
2836

dragonfly/documentation/actions.html

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5-
<title>Action framework &mdash; Dragonfly v0.6.4rc3 documentation</title>
5+
<title>Actions sub-package &mdash; Dragonfly v0.6.4rc3 documentation</title>
66
<link rel="stylesheet" href="_static/default.css" type="text/css" />
77
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
88
<script type="text/javascript">
@@ -47,24 +47,31 @@ <h3>Navigation</h3>
4747
<div class="body">
4848

4949

50-
<div class="section" id="action-framework">
51-
<h1>Action framework<a class="headerlink" href="#action-framework" title="Permalink to this headline"></a></h1>
52-
<p>The Dragonfly library contains an action framework which which
53-
offers easy and flexible interfaces to common actions, such as
54-
emulating keystrokes. These action types have been objectified,
55-
which means that they are first-class Python objects and can be
56-
treated as such.</p>
50+
<div class="section" id="actions-sub-package">
51+
<h1>Actions sub-package<a class="headerlink" href="#actions-sub-package" title="Permalink to this headline"></a></h1>
52+
<p>The Dragonfly library contains an action framework which offers easy and
53+
flexible interfaces to common actions, such as sending keystrokes and
54+
emulating speech recognition. Dragonfly&#8217;s actions sub-package has various
55+
types of these actions, each consisting of a Python class. There is for
56+
example a <a title="dragonfly.actions.action_key.Key" class="reference internal" href="#dragonfly.actions.action_key.Key"><tt class="xref docutils literal"><span class="pre">dragonfly.actions.action_key.Key</span></tt></a> class for sending
57+
keystrokes and a <a title="dragonfly.actions.action_mimic.Mimic" class="reference internal" href="#dragonfly.actions.action_mimic.Mimic"><tt class="xref docutils literal"><span class="pre">dragonfly.actions.action_mimic.Mimic</span></tt></a> class for
58+
emulating speech recognition.</p>
59+
<p>Each of these actions is implemented as a Python class and this makes it
60+
easy to work with them. An action can be created (<em>defined what it will
61+
do</em>) at one point and executed (<em>do what it was defined to do</em>) later.
62+
Actions can be added together with the <tt class="docutils literal"><span class="pre">+</span></tt> operator to attend them
63+
together, thereby creating series of actions.</p>
5764
<p>Perhaps the most important method of Dragonfly&#8217;s actions is their
5865
<tt class="xref docutils literal"><span class="pre">dragonfly.actions.action_base.ActionBase.execute()</span></tt> method, which
59-
performs the actual event associated with them.</p>
66+
performs the actual event associated with its action.</p>
6067
<p>Dragonfly&#8217;s action types are derived from the
6168
<a title="dragonfly.actions.action_base.ActionBase" class="reference internal" href="#dragonfly.actions.action_base.ActionBase"><tt class="xref docutils literal"><span class="pre">dragonfly.actions.action_base.ActionBase</span></tt></a> class. This base class
6269
implements standard action behavior, such as the ability to concatenate
6370
multiple actions and to duplicate an action.</p>
6471
<div class="section" id="basic-examples">
6572
<h2>Basic examples<a class="headerlink" href="#basic-examples" title="Permalink to this headline"></a></h2>
66-
<p>The code below shows the basic usage of Dragonfly action
67-
objects. They can be created, combined, executed, etc.</p>
73+
<p>The code below shows the basic usage of Dragonfly action objects. They
74+
can be created, combined, executed, etc.</p>
6875
<div class="highlight"><pre><span class="kn">from</span> <span class="nn">dragonfly.all</span> <span class="kn">import</span> <span class="n">Key</span><span class="p">,</span> <span class="n">Text</span>
6976

7077
<span class="n">a1</span> <span class="o">=</span> <span class="n">Key</span><span class="p">(</span><span class="s">&quot;up, left, down, right&quot;</span><span class="p">)</span> <span class="c"># Define action a1.</span>
@@ -381,7 +388,7 @@ <h3>WaitWindow action &#8211; wait for a specific window context<a class="header
381388
specified using the constructor arguments listed above. The
382389
substring search used is <em>not</em> case sensitive.</p>
383390
<p>If the correct window context is not found within <em>timeout</em>
384-
seconds, then this action will raise an :class`ActionError` to
391+
seconds, then this action will raise an <tt class="xref docutils literal"><span class="pre">ActionError</span></tt> to
385392
indicate the timeout.</p>
386393
</dd></dl>
387394

@@ -419,7 +426,7 @@ <h3>Pause action &#8211; wait for a specific amount of time<a class="headerlink"
419426
<div class="sphinxsidebarwrapper">
420427
<h3>Table Of Contents</h3>
421428
<ul>
422-
<li><a class="reference external" href="">Action framework</a><ul>
429+
<li><a class="reference external" href="">Actions sub-package</a><ul>
423430
<li><a class="reference external" href="#basic-examples">Basic examples</a></li>
424431
<li><a class="reference external" href="#combining-voice-commands-and-actions">Combining voice commands and actions</a></li>
425432
<li><a class="reference external" href="#module-dragonfly.actions.action_pause">Action class reference</a><ul>
@@ -480,7 +487,7 @@ <h3>Navigation</h3>
480487
</div>
481488
<div class="footer">
482489
&copy; Copyright 2008, Christo Butcher.
483-
Last updated on Jan 31, 2009.
490+
Last updated on Feb 01, 2009.
484491
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
485492
</div>
486493
</body>

dragonfly/documentation/clipboard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ <h3>Navigation</h3>
251251
</div>
252252
<div class="footer">
253253
&copy; Copyright 2008, Christo Butcher.
254-
Last updated on Jan 31, 2009.
254+
Last updated on Feb 01, 2009.
255255
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
256256
</div>
257257
</body>

dragonfly/documentation/compound.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ <h3>Navigation</h3>
111111
</div>
112112
<div class="footer">
113113
&copy; Copyright 2008, Christo Butcher.
114-
Last updated on Jan 31, 2009.
114+
Last updated on Feb 01, 2009.
115115
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
116116
</div>
117117
</body>

0 commit comments

Comments
 (0)