Skip to content

Commit 1356572

Browse files
committed
Added folder sync to Cloud Files. Fixed several unicode issues. Removed lazy load in Cloud Databases volume information.
1 parent 5dd45aa commit 1356572

33 files changed

+473
-58
lines changed

RELEASENOTES.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Release Notes for pyrax
22

3+
2013.02.05 - Added the `sync_folder_to_container()` method to cloudfiles to make it
4+
easier to keep a copy of a local folder synced to the cloud.
5+
- Removed the lazy load of volume info for cloud databases. Changed the
6+
'volume' attribute to be an object to allow for dot notation access
7+
to its values.
8+
- Eliminated as many places as possible where use of non-ASCII characters
9+
caused encoding issues. Added a configuration option to allow users to
10+
specify their preferred encoding; default=utf-8.
11+
- Fixed a bug in the `get_object_names()` method of the Cloud Files
12+
container class.
13+
314
2013.01.26 - Fixed an issue preventing existing node objects being created if in
415
'DRAINING' condition (GitHub #6). Modified the rax_identity to accept
516
UTC dates returned from the LON datacenter (GitHub #5). Fixed an

docs/cloud_files.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,26 @@ Since a folder upload can take a while, the uploading happens in a background th
213213
Sometimes it is necessary to stop a folder upload before it has completed. To do this, call `cloudfiles.cancel_folder_upload(upload_key)`, which will cause the background thread to stop uploading.
214214

215215

216+
## Syncing a Local Folder with a Container
217+
Another common use case is to use Cloud Files as a backup of the important files on your local machine. `pyrax` provides the `sync_folder_to_container()` method that makes this straightforward. It takes the following parameters:
218+
219+
Parameter | Required? | Description | Default
220+
---- | ---- | ---- | ----
221+
**folder_path** | yes | Full path to the folder on your local machine | n/a
222+
**container** | yes | Either the name of an existing container, or an actual container object | n/a
223+
**include_hidden** | no | When False, files in your folder that begin with a period are ignored | False
224+
**ignore_timestamps** | no | When False, if the local file and remote object differ, the local file is uploaded and overwrites the remote. When True, the local file's modification time is compared with the remote object's last_modified time, and the remote object is only overwritten if the local file is newer. | False
225+
226+
As an example, assume you have a project named 'important' that you want to make sure is always backed up to Cloud Files. You could write a quick script like this, and call it from a cron job.
227+
228+
cf = pyrax.cloudfiles
229+
local = "/home/myname/projects/important"
230+
remote = cf.create_container("important_files")
231+
cf.sync_folder_to_container(local, remote)
232+
233+
This would sync all of the files in that folder, except for hidden files, such as .git subdirectories, or the .swp files that vim creates.
234+
235+
216236
## Listing Objects in a Container
217237
Assuming you have a `Container` object, simply call:
218238

docs/cloud_servers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ Since each `Server` object has a `delete()` method, it is simple to delete all t
209209
If you have a `Server` object and want to create an image of that server, you can call its `create_image()` method, passing in the name of the image to create, along with any optional metadata for the image.
210210

211211
cs = pyrax.cloudservers
212-
server = cs.get(id_of_server)
212+
server = cs.servers.get(id_of_server)
213213
server.create_image("my_image_name")
214214

215215
Another option is to use call `pyrax.servers.create_image()`, passing in either the name or the ID of the server from which you want to create the image, along with the image name and optional metadata.
@@ -224,7 +224,7 @@ Resizing a server is the process of changing the amount of resources allocated t
224224
Resizing is a multi-step process. First, determine the desired `Flavor` to which the server is to be resized. Then call the `resize()` method on the server, passing in the ID of the desired `Flavor`. The server's status will then be set to "RESIZE".
225225

226226
cs = pyrax.cloudservers
227-
server = cs.get(id_of_server)
227+
server = cs.servers.get(id_of_server)
228228
server.resize(new_flavor_ID)
229229

230230
On the host, a new server instance with the new flavor size will be created based on your existing server. When it is ready, the ID, name, networking, and so forth for the current server instance will be transferred to the new instance. At that point, `get(ID)` will return the new instance, and it will have a status of "CONFIRM_RESIZE". Now you will need to determine if the resize was successful, and that the server is functioning properly. If all is well, call:

docs/html/____init_____8py.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@
143143
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepyrax.html#affa3c4afe67ff7c721e823ac8b67fa16">default_region</a> = None</td></tr>
144144
<tr><td class="memItemLeft" align="right" valign="top">string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepyrax.html#a395a063eb4a0103b5e6924806e1a7c00">FALLBACK_REGION</a> = &quot;DFW&quot;</td></tr>
145145
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepyrax.html#a29094260a6921954174501a2f1df2d2f">keyring_username</a> = None</td></tr>
146+
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepyrax.html#ab1000d1f2ea9878f60bc119650013894">encoding</a> = None</td></tr>
147+
<tr><td class="memItemLeft" align="right" valign="top">string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepyrax.html#afe27f0e1c4864c0be1ff0061994415f2">DEFAULT_ENCODING</a> = &quot;utf-8&quot;</td></tr>
146148
<tr><td class="memItemLeft" align="right" valign="top">string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepyrax.html#af2dfe76f6f24fbcdfd28b75ed32ada24">USER_AGENT</a> = &quot;pyrax/%s&quot;</td></tr>
147149
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepyrax.html#a6e3493c19e86089da9cd511800adbde3">_http_debug</a> = False</td></tr>
148150
<tr><td class="memItemLeft" align="right" valign="top">tuple&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacepyrax.html#ae6512f1802b7f1f9cc6f196a0938db60">config_file</a> = os.path.expanduser(&quot;~/.pyrax.cfg&quot;)</td></tr>
@@ -165,7 +167,7 @@
165167

166168

167169
<hr class="footer"/><address class="footer"><small>
168-
Generated on Tue Jan 15 2013 17:17:39 for pyrax by &#160;<a href="http://www.doxygen.org/index.html">
170+
Generated on Tue Feb 5 2013 13:13:12 for pyrax by &#160;<a href="http://www.doxygen.org/index.html">
169171
<img class="footer" src="doxygen.png" alt="doxygen"/>
170172
</a> 1.7.6.1
171173
</small></address>

docs/html/classpyrax_1_1cf__wrapper_1_1client_1_1CFClient-members.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
<tr class="memlist"><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html#a77469aa965e7df1c81ad902bea324a36">set_container_web_index_page</a></td><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html">CFClient</a></td><td></td></tr>
137137
<tr class="memlist"><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html#a684f0273a86b04ee46bf5a7304df768d">set_object_metadata</a></td><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html">CFClient</a></td><td></td></tr>
138138
<tr class="memlist"><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html#af0a50c69bbe50a35557fb373cf3b4b6f">store_object</a></td><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html">CFClient</a></td><td></td></tr>
139+
<tr class="memlist"><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html#af2b0d6de7b4f7cb42d5ecef34b239907">sync_folder_to_container</a></td><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html">CFClient</a></td><td></td></tr>
139140
<tr class="memlist"><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html#a3857f84faa9608b0bf0a4e84ba5b1566">upload_file</a></td><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html">CFClient</a></td><td></td></tr>
140141
<tr class="memlist"><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html#a1d81cba43ddabd40e412c5d709192958">upload_folder</a></td><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html">CFClient</a></td><td></td></tr>
141142
<tr class="memlist"><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html#ac1b27022e729d81b2b33590aea822188">user_agent</a></td><td><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html">CFClient</a></td><td><code> [static]</code></td></tr>
@@ -157,7 +158,7 @@
157158

158159

159160
<hr class="footer"/><address class="footer"><small>
160-
Generated on Mon Dec 17 2012 18:02:49 for pyrax by &#160;<a href="http://www.doxygen.org/index.html">
161+
Generated on Tue Feb 5 2013 13:13:12 for pyrax by &#160;<a href="http://www.doxygen.org/index.html">
161162
<img class="footer" src="doxygen.png" alt="doxygen"/>
162163
</a> 1.7.6.1
163164
</small></address>

docs/html/classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@
153153
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Uploads the specified file to the container. <a href="#a3857f84faa9608b0bf0a4e84ba5b1566"></a><br/></td></tr>
154154
<tr><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html#a1d81cba43ddabd40e412c5d709192958">upload_folder</a></td></tr>
155155
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Convenience method for uploading an entire folder, including any sub-folders, to Cloud Files. <a href="#a1d81cba43ddabd40e412c5d709192958"></a><br/></td></tr>
156+
<tr><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html#af2b0d6de7b4f7cb42d5ecef34b239907">sync_folder_to_container</a></td></tr>
157+
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Compares the contents of the specified folder, and checks to make sure that the corresponding object is present in the specified container. <a href="#af2b0d6de7b4f7cb42d5ecef34b239907"></a><br/></td></tr>
156158
<tr><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html#a537487e2f2dabc8103e2006739cbeb0e">get_uploaded</a></td></tr>
157159
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the number of bytes uploaded for the specified process. <a href="#a537487e2f2dabc8103e2006739cbeb0e"></a><br/></td></tr>
158160
<tr><td class="memItemLeft" align="right" valign="top">def&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html#a621a0e61fdb17290b5e9f5dec5eb12fc">cancel_folder_upload</a></td></tr>
@@ -1535,6 +1537,62 @@
15351537

15361538
<p>Creates a new object in the specified container, and populates it with the given data. </p>
15371539

1540+
</div>
1541+
</div>
1542+
<a class="anchor" id="af2b0d6de7b4f7cb42d5ecef34b239907"></a><!-- doxytag: member="pyrax::cf_wrapper::client::CFClient::sync_folder_to_container" ref="af2b0d6de7b4f7cb42d5ecef34b239907" args="" -->
1543+
<div class="memitem">
1544+
<div class="memproto">
1545+
<table class="memname">
1546+
<tr>
1547+
<td class="memname">def <a class="el" href="classpyrax_1_1cf__wrapper_1_1client_1_1CFClient.html#af2b0d6de7b4f7cb42d5ecef34b239907">sync_folder_to_container</a> </td>
1548+
<td>(</td>
1549+
<td class="paramtype">&#160;</td>
1550+
<td class="paramname"><em>self</em>, </td>
1551+
</tr>
1552+
<tr>
1553+
<td class="paramkey"></td>
1554+
<td></td>
1555+
<td class="paramtype">&#160;</td>
1556+
<td class="paramname"><em>folder_path</em>, </td>
1557+
</tr>
1558+
<tr>
1559+
<td class="paramkey"></td>
1560+
<td></td>
1561+
<td class="paramtype">&#160;</td>
1562+
<td class="paramname"><em>container</em>, </td>
1563+
</tr>
1564+
<tr>
1565+
<td class="paramkey"></td>
1566+
<td></td>
1567+
<td class="paramtype">&#160;</td>
1568+
<td class="paramname"><em>delete</em> = <code>False</code>, </td>
1569+
</tr>
1570+
<tr>
1571+
<td class="paramkey"></td>
1572+
<td></td>
1573+
<td class="paramtype">&#160;</td>
1574+
<td class="paramname"><em>include_hidden</em> = <code>False</code>, </td>
1575+
</tr>
1576+
<tr>
1577+
<td class="paramkey"></td>
1578+
<td></td>
1579+
<td class="paramtype">&#160;</td>
1580+
<td class="paramname"><em>ignore_timestamps</em> = <code>False</code>&#160;</td>
1581+
</tr>
1582+
<tr>
1583+
<td></td>
1584+
<td>)</td>
1585+
<td></td><td></td>
1586+
</tr>
1587+
</table>
1588+
</div>
1589+
<div class="memdoc">
1590+
1591+
<p>Compares the contents of the specified folder, and checks to make sure that the corresponding object is present in the specified container. </p>
1592+
<p>If there is no remote object matching the local file, it is created. If a matching object exists, the etag is examined to determine if the object in the container matches the local file; if they differ, the container is updated with the local file if the local file is newer when `ignore_timestamps' is False (default). If `ignore_timestamps` is True, the object is overwritten with the local file contents whenever the etags differ. NOTE: the timestamp of a remote object is the time it was uploaded, not the original modification time of the file stored in that object.</p>
1593+
<p>Unless 'include_hidden' is True, files beginning with an initial period are ignored.</p>
1594+
<p>If the 'delete' option is True, any objects in the container that do not have corresponding files in the local folder are deleted. </p>
1595+
15381596
</div>
15391597
</div>
15401598
<a class="anchor" id="a3857f84faa9608b0bf0a4e84ba5b1566"></a><!-- doxytag: member="pyrax::cf_wrapper::client::CFClient::upload_file" ref="a3857f84faa9608b0bf0a4e84ba5b1566" args="" -->
@@ -1805,7 +1863,7 @@
18051863

18061864

18071865
<hr class="footer"/><address class="footer"><small>
1808-
Generated on Mon Dec 17 2012 18:02:49 for pyrax by &#160;<a href="http://www.doxygen.org/index.html">
1866+
Generated on Tue Feb 5 2013 13:13:12 for pyrax by &#160;<a href="http://www.doxygen.org/index.html">
18091867
<img class="footer" src="doxygen.png" alt="doxygen"/>
18101868
</a> 1.7.6.1
18111869
</small></address>

docs/html/classpyrax_1_1cf__wrapper_1_1container_1_1Container.html

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,14 +427,49 @@
427427
<td class="memname">def <a class="el" href="classpyrax_1_1cf__wrapper_1_1container_1_1Container.html#a1ffef9ff929707223146f6c5373e2a14">get_object_names</a> </td>
428428
<td>(</td>
429429
<td class="paramtype">&#160;</td>
430-
<td class="paramname"><em>self</em></td><td>)</td>
430+
<td class="paramname"><em>self</em>, </td>
431+
</tr>
432+
<tr>
433+
<td class="paramkey"></td>
434+
<td></td>
435+
<td class="paramtype">&#160;</td>
436+
<td class="paramname"><em>marker</em> = <code>None</code>, </td>
437+
</tr>
438+
<tr>
439+
<td class="paramkey"></td>
440+
<td></td>
441+
<td class="paramtype">&#160;</td>
442+
<td class="paramname"><em>limit</em> = <code>None</code>, </td>
443+
</tr>
444+
<tr>
445+
<td class="paramkey"></td>
446+
<td></td>
447+
<td class="paramtype">&#160;</td>
448+
<td class="paramname"><em>prefix</em> = <code>None</code>, </td>
449+
</tr>
450+
<tr>
451+
<td class="paramkey"></td>
452+
<td></td>
453+
<td class="paramtype">&#160;</td>
454+
<td class="paramname"><em>delimiter</em> = <code>None</code>, </td>
455+
</tr>
456+
<tr>
457+
<td class="paramkey"></td>
431458
<td></td>
459+
<td class="paramtype">&#160;</td>
460+
<td class="paramname"><em>full_listing</em> = <code>False</code>&#160;</td>
461+
</tr>
462+
<tr>
463+
<td></td>
464+
<td>)</td>
465+
<td></td><td></td>
432466
</tr>
433467
</table>
434468
</div>
435469
<div class="memdoc">
436470

437471
<p>Returns a list of the names of all the objects in this container. </p>
472+
<p>The same pagination parameters apply as in self.get_objects(). </p>
438473

439474
</div>
440475
</div>
@@ -928,7 +963,7 @@
928963

929964

930965
<hr class="footer"/><address class="footer"><small>
931-
Generated on Tue Nov 20 2012 15:03:05 for pyrax by &#160;<a href="http://www.doxygen.org/index.html">
966+
Generated on Tue Feb 5 2013 13:13:12 for pyrax by &#160;<a href="http://www.doxygen.org/index.html">
932967
<img class="footer" src="doxygen.png" alt="doxygen"/>
933968
</a> 1.7.6.1
934969
</small></address>

docs/html/functions_0x68.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ <h3><a class="anchor" id="index_h"></a>- h -</h3><ul>
134134
, <a class="el" href="classpyrax_1_1exceptions_1_1NoUniqueMatch.html#adc16a229378030a650cd7e8d6dc16677">NoUniqueMatch</a>
135135
, <a class="el" href="classpyrax_1_1exceptions_1_1BadRequest.html#adc16a229378030a650cd7e8d6dc16677">BadRequest</a>
136136
</li>
137-
<li>HUMAN_ID
138-
: <a class="el" href="classpyrax_1_1resource_1_1BaseResource.html#a494d50825f5dfc848a56d8a568c16172">BaseResource</a>
139-
</li>
140137
<li>human_id()
141138
: <a class="el" href="classpyrax_1_1resource_1_1BaseResource.html#a386641658f158d35fbe6af4c8e0d128a">BaseResource</a>
142139
</li>
140+
<li>HUMAN_ID
141+
: <a class="el" href="classpyrax_1_1resource_1_1BaseResource.html#a494d50825f5dfc848a56d8a568c16172">BaseResource</a>
142+
</li>
143143
</ul>
144144
</div><!-- contents -->
145145
<!-- window showing the filter options -->
@@ -159,7 +159,7 @@ <h3><a class="anchor" id="index_h"></a>- h -</h3><ul>
159159

160160

161161
<hr class="footer"/><address class="footer"><small>
162-
Generated on Mon Dec 24 2012 16:05:48 for pyrax by &#160;<a href="http://www.doxygen.org/index.html">
162+
Generated on Tue Feb 5 2013 13:13:14 for pyrax by &#160;<a href="http://www.doxygen.org/index.html">
163163
<img class="footer" src="doxygen.png" alt="doxygen"/>
164164
</a> 1.7.6.1
165165
</small></address>

0 commit comments

Comments
 (0)