Browse Source

update rst readme, remove unused import

dependabot/add-v2-config-file
R4SAS 6 years ago
parent
commit
dc034b1d55
  1. 2
      README.md
  2. 45
      README.rst
  3. 2
      pbincli/actions.py
  4. 4
      pbincli/api.py
  5. 1
      pbincli/format.py

2
README.md

@ -23,7 +23,7 @@ You can create config file with variables `server` and `proxy` in `~/.config/pbi
Example contents: Example contents:
``` ```ini
server=https://paste.i2pd.xyz/ server=https://paste.i2pd.xyz/
proxy=http://127.0.0.1:3128 proxy=http://127.0.0.1:3128
``` ```

45
README.rst

@ -10,81 +10,74 @@
:alt: GitHub tag :alt: GitHub tag
.. image:: https://img.shields.io/github/release/r4sas/PBinCLI.svg .. image:: https://api.codacy.com/project/badge/Grade/4f24f43356a84621bbd9078c4b3f1b70
:target: https://github.com/r4sas/PBinCLI/releases/ :target: https://www.codacy.com/app/r4sas/PBinCLI?utm_source=github.com&utm_medium=referral&utm_content=r4sas/PBinCLI&utm_campaign=Badge_Grade
:alt: GitHub release :alt: Codacy Badge
PBinCLI PBinCLI
======= =======
`PrivateBin <https://github.com/PrivateBin/PrivateBin/>`_ CLI PBinCLI is command line client for `PrivateBin <https://github.com/PrivateBin/PrivateBin/>`_ written on Python 3.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Installing Installing
---------- ----------
.. code-block:: bash .. code-block:: bash
$ virtualenv --python=python3 venv virtualenv --python=python3 venv
$ . venv/bin/activate . venv/bin/activate
$ pip install pbincli pip install pbincli
Usage Usage
----- -----
By default pbincli configured to use https://paste.i2pd.xyz/ for sending and receiving pastes. No proxy used by default. By default pbincli configured to use ``https://paste.i2pd.xyz/`` for sending and receiving pastes. No proxy used by default.
You can create config file with variables ``server`` and ``proxy`` in ``~/.config/pbincli/pbincli.conf`` to use different settings. You can create config file with variables ``server`` and ``proxy`` in ``~/.config/pbincli/pbincli.conf`` to use different settings.
Example contents: Example contents:
.. code-block:: .. code-block:: ini
server=https://paste.i2pd.xyz/ server=https://paste.i2pd.xyz/
proxy=http://127.0.0.1:3128 proxy=http://127.0.0.1:3128
Run inside ``venv`` command: Run inside ``venv`` command:
.. code-block:: .. code-block:: bash
$ pbincli send --text "Hello!"
pbincli send --text "Hello!"
Or use stdin input to read text for paste: Or use stdin input to read text for paste:
.. code-block:: .. code-block:: bash
$ pbincli send - <<EOF pbincli send - <<EOF
Hello! This is test paste! Hello! This is test paste!
EOF EOF
It will send string ``Hello! This is test paste!`` to PrivateBin. It will send string ``Hello! This is test paste!`` to PrivateBin.
To send file use ``--file`` or ``-f`` with filename. Example: To send file use ``--file`` or ``-f`` with filename. Example:
.. code-block:: .. code-block:: bash
$ pbincli send -c "My document" -f info.pdf
pbincli send -c "My document" -f info.pdf
To retrieve paste from server, use ``get`` command with paste info. To retrieve paste from server, use ``get`` command with paste info.
It must be formated like ``pasteID#passphrase``. Example: It must be formated like ``pasteID#passphrase``. Example:
.. code-block:: .. code-block:: bash
$ pbincli get 49eeb1326cfa9491#vfeortoVWaYeJlviDdhxQBtj5e0I2kArpynrtu/tnGs=
pbincli get 49eeb1326cfa9491#vfeortoVWaYeJlviDdhxQBtj5e0I2kArpynrtu/tnGs=
More info you can find by typing More info you can find by typing
.. code-block:: .. code-block:: bash
$ pbincli [-h] {send, get, delete}
pbincli [-h] {send, get, delete}
TODO TODO
---- ----

2
pbincli/actions.py

@ -76,7 +76,7 @@ def get(args, api_client):
try: try:
pasteid, passphrase = args.pasteinfo.split("#") pasteid, passphrase = args.pasteinfo.split("#")
except: except ValueError:
print("PBinCLI error: provided info hasn't contain valid PasteID#Passphrase string") print("PBinCLI error: provided info hasn't contain valid PasteID#Passphrase string")
exit(1) exit(1)

4
pbincli/api.py

@ -19,7 +19,7 @@ class PrivateBin:
try: try:
return result.json() return result.json()
except: except ValueError:
print("ERROR: Unable parse response as json. Received (size = {}):\n{}".format(len(result.text), result.text)) print("ERROR: Unable parse response as json. Received (size = {}):\n{}".format(len(result.text), result.text))
exit(1) exit(1)
@ -40,7 +40,7 @@ class PrivateBin:
headers = self.headers, headers = self.headers,
proxies = self.proxy, proxies = self.proxy,
data = request).json() data = request).json()
except: except ValueError:
# unable parse response as json because it can be empty (1.2), so simulate correct answer # unable parse response as json because it can be empty (1.2), so simulate correct answer
print("NOTICE: Received empty response. We interpret that as our paste has already been deleted.") print("NOTICE: Received empty response. We interpret that as our paste has already been deleted.")
from json import loads as json_loads from json import loads as json_loads

1
pbincli/format.py

@ -186,7 +186,6 @@ class Paste:
self._attachment = cipher_message['attachment'] self._attachment = cipher_message['attachment']
self._attachment_name = cipher_message['attachment_name'] self._attachment_name = cipher_message['attachment_name']
else: else:
from hashlib import sha256
from sjcl import SJCL from sjcl import SJCL
password = self.__preparePassKey() password = self.__preparePassKey()

Loading…
Cancel
Save