Permalink
Browse files

Modified Size docs.

  • Loading branch information...
1 parent 1fe34d3 commit 4264a91e5087ac532931b5b1cb80691056a61102 @xzased committed May 4, 2012
Showing with 76 additions and 5 deletions.
  1. +4 −0 .buildinfo
  2. +2 −2 index.html
  3. +2 −2 quickstart.html
  4. +1 −1 searchindex.js
  5. +67 −0 sources/quickstart.txt
View
@@ -0,0 +1,4 @@
+# Sphinx build info version 1
+# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
+config: 6401eccea73da0a8d5ba67971c9b4ee2
+tags: fbb0d17656682115ca4d033fb2f83ba1
View
@@ -215,7 +215,7 @@
<span class="c"># get the sector size from the device</span>
<span class="n">myDevice</span> <span class="o">=</span> <span class="n">Device</span><span class="p">(</span><span class="s">&#39;/dev/sda&#39;</span><span class="p">)</span>
-<span class="n">mySize</span> <span class="o">=</span> <span class="n">Size</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="s">&quot;GB&quot;</span><span class="p">,</span> <span class="n">myDevice</span><span class="p">)</span>
+<span class="n">mySize</span> <span class="o">=</span> <span class="n">Size</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="s">&quot;GB&quot;</span><span class="p">,</span> <span class="n">dev</span><span class="o">=</span><span class="n">myDevice</span><span class="p">)</span>
</pre></div>
</div>
<p>There is an option to choose percentage <em>&#8216;%&#8217;</em> as units, in which case
@@ -224,7 +224,7 @@
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">reparted</span> <span class="kn">import</span> <span class="o">*</span>
<span class="n">myDevice</span> <span class="o">=</span> <span class="n">Device</span><span class="p">(</span><span class="s">&#39;/dev/sda&#39;</span><span class="p">)</span>
-<span class="n">mySize</span> <span class="o">=</span> <span class="n">Size</span><span class="p">(</span><span class="mi">25</span><span class="p">,</span> <span class="s">&quot;%&quot;</span><span class="p">,</span> <span class="n">myDevice</span><span class="p">)</span>
+<span class="n">mySize</span> <span class="o">=</span> <span class="n">Size</span><span class="p">(</span><span class="mi">25</span><span class="p">,</span> <span class="s">&quot;%&quot;</span><span class="p">,</span> <span class="n">dev</span><span class="o">=</span><span class="n">myDevice</span><span class="p">)</span>
</pre></div>
</div>
<dl class="docutils">
View
@@ -90,11 +90,11 @@
<span class="c"># get the sector size from the device</span>
<span class="n">myDevice</span> <span class="o">=</span> <span class="n">Device</span><span class="p">(</span><span class="s">&#39;/dev/sda&#39;</span><span class="p">)</span>
-<span class="n">mySize</span> <span class="o">=</span> <span class="n">Size</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="s">&quot;GB&quot;</span><span class="p">,</span> <span class="n">myDevice</span><span class="p">)</span>
+<span class="n">mySize</span> <span class="o">=</span> <span class="n">Size</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="s">&quot;GB&quot;</span><span class="p">,</span> <span class="n">dev</span><span class="o">=</span><span class="n">myDevice</span><span class="p">)</span>
<span class="c"># You can even set a percentage!</span>
<span class="n">myDevice</span> <span class="o">=</span> <span class="n">Device</span><span class="p">(</span><span class="s">&#39;/dev/sda&#39;</span><span class="p">)</span>
-<span class="n">mySize</span> <span class="o">=</span> <span class="n">Size</span><span class="p">(</span><span class="mi">25</span><span class="p">,</span> <span class="s">&quot;%&quot;</span><span class="p">,</span> <span class="n">myDevice</span><span class="p">)</span>
+<span class="n">mySize</span> <span class="o">=</span> <span class="n">Size</span><span class="p">(</span><span class="mi">25</span><span class="p">,</span> <span class="s">&quot;%&quot;</span><span class="p">,</span> <span class="n">dev</span><span class="o">=</span><span class="n">myDevice</span><span class="p">)</span>
</pre></div>
</div>
<p>Now that you have your size, you can initialize a new partition and add it to disk:</p>
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,67 @@
+Quickstart
+================
+Here is the guide for the impatient::
+
+ from reparted import *
+
+ # Initialize a device instance, you can provide the path
+ myDevice = Device("/dev/sda")
+
+ # Or you can let it probe standard devices, it will default to the first
+ # one it finds.
+ myDevice = Device()
+
+ # Initialize our disk.
+ myDisk = Disk(myDevice)
+
+ # If this is a fresh disk (no partition table set) you can go ahead
+ # and set the partition table.
+ myDisk.set_label('gpt')
+ myDisk.commit()
+
+You can test if your disk is set with a partition table like this::
+
+ if myDisk.type_name is None:
+ # No partition table, set one
+ myDisk.set_label('gpt')
+ mydisk.commit()
+
+ # You can see if your disk has any partitions
+ partitions = myDisk.partitions()
+
+You can add partitions, but first you need to set the size::
+
+ # sector size defaults to 512
+ mySize1 = Size(4, "GB")
+
+ # manually set the sector size to 1024
+ mySize2 = Size(4, "GB", sector_size=1024)
+
+ # get the sector size from the device
+ myDevice = Device('/dev/sda')
+ mySize = Size(4, "GB", dev=myDevice)
+
+ # You can even set a percentage!
+ myDevice = Device('/dev/sda')
+ mySize = Size(25, "%", dev=myDevice)
+
+Now that you have your size, you can initialize a new partition and add it to disk::
+
+ myPartition = Partition(myDisk, mySize)
+ myDisk.add_partition(myPartition)
+ myDisk.commit()
+
+You can also delete partitions::
+
+ partition = myDisk.partitions()[0]
+ myDisk.delete_partition(partition)
+
+Or just delete them all::
+
+ myDisk.delete_all()
+
+
+Checkout the module reference for more available options.
+
+.. note::
+ You must have libparted installed and available from your LD_LIBRARY_PATH

0 comments on commit 4264a91

Please sign in to comment.