Compare commits

..

No commits in common. '7413bad322266b0a763ffe0668c52717d5f19f41' and '08dbceebc63ecb48f248ff1587ca3b80c6b249f7' have entirely different histories.

  1. 6
      .github/workflows/binary.yml
  2. 1
      README.md
  3. 3
      README.rst
  4. 25
      pbincli/actions.py
  5. 2
      pbincli/cli.py
  6. 11
      pbincli/utils.py

6
.github/workflows/binary.yml

@ -7,9 +7,9 @@ jobs: @@ -7,9 +7,9 @@ jobs:
name: Binary for windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- name: Setup python 3.8
uses: actions/setup-python@v4
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Build executable with pyinstaller
@ -18,7 +18,7 @@ jobs: @@ -18,7 +18,7 @@ jobs:
pip install .
pip install pyinstaller pywin32-ctypes
pyinstaller pbincli.spec
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v2
with:
name: pbincli-windows
path: dist/*

1
README.md

@ -54,7 +54,6 @@ proxy=http://127.0.0.1:3128 @@ -54,7 +54,6 @@ proxy=http://127.0.0.1:3128
| short_user | None | Used only in `yourls` |
| short_pass | None | Used only in `yourls` |
| short_token | None | Used only in `yourls` |
| output | None | Path to the directory where the received data will be saved |
| no_check_certificate | False | True / False |
| no_insecure_warning | False | True / False |
| compression | zlib | zlib / none |

3
README.rst

@ -104,9 +104,6 @@ List of OPTIONS available @@ -104,9 +104,6 @@ List of OPTIONS available
* - short_token
- None
- Used only in ``yourls``
* - output
- None
- Path to the directory where the received data will be saved
* - no_check_certificate
- False
- True / False

25
pbincli/actions.py

@ -3,7 +3,7 @@ from urllib.parse import parse_qsl @@ -3,7 +3,7 @@ from urllib.parse import parse_qsl
from pbincli.api import Shortener
from pbincli.format import Paste
from pbincli.utils import PBinCLIError, check_writable, json_encode, uri_validator, validate_url_ending, validate_path_ending
from pbincli.utils import PBinCLIError, check_writable, json_encode, uri_validator, validate_url_ending
def signal_handler(sig, frame):
@ -166,30 +166,21 @@ def get(args, api_client, settings=None): @@ -166,30 +166,21 @@ def get(args, api_client, settings=None):
if len(text):
if args.debug: print("{}\n".format(text.decode()))
if settings['output']:
paste_path = validate_path_ending(settings['output']) + "paste-" + pasteid + ".txt"
else:
paste_path = "paste-" + pasteid + ".txt"
print("Found text in paste. Saving it to {}".format(paste_path))
filename = "paste-" + pasteid + ".txt"
print("Found text in paste. Saving it to {}".format(filename))
check_writable(paste_path)
with open(paste_path, "wb") as f:
check_writable(filename)
with open(filename, "wb") as f:
f.write(text)
f.close()
attachment, attachment_name = paste.getAttachment()
if attachment:
if settings['output']:
attachment_path = validate_path_ending(settings['output']) + attachment_name
else:
attachment_path = attachment_name
print("Found file, attached to paste. Saving it to {}\n".format(attachment_path))
print("Found file, attached to paste. Saving it to {}\n".format(attachment_name))
check_writable(attachment_path)
with open(attachment_path, "wb") as f:
check_writable(attachment_name)
with open(attachment_name, "wb") as f:
f.write(attachment)
f.close()

2
pbincli/cli.py

@ -81,7 +81,6 @@ def main(): @@ -81,7 +81,6 @@ def main():
get_parser = subparsers.add_parser("get", description="Get data from PrivateBin instance")
get_parser.add_argument("pasteinfo", help="\"PasteID#Passphrase\" or full URL")
get_parser.add_argument("-p", "--password", help="Password for decrypting paste")
get_parser.add_argument("-o", "--output", default=argparse.SUPPRESS, help="Path to directory where decoded paste data will be saved")
## Connection options
get_parser.add_argument("-s", "--server", default=argparse.SUPPRESS, help="Instance URL (default: https://paste.i2pd.xyz/, ignored if URL used in pasteinfo)")
get_parser.add_argument("-x", "--proxy", default=argparse.SUPPRESS, help="Proxy server address (default: None)")
@ -125,7 +124,6 @@ def main(): @@ -125,7 +124,6 @@ def main():
'short_user': None,
'short_pass': None,
'short_token': None,
'output': None,
'no_check_certificate': False,
'no_insecure_warning': False,
'compression': None

11
pbincli/utils.py

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
import json, ntpath, os, sys
from platform import system
class PBinCLIException(Exception):
pass
@ -36,16 +35,6 @@ def validate_url_ending(s): @@ -36,16 +35,6 @@ def validate_url_ending(s):
s = s + "/"
return s
def validate_path_ending(s):
if system() == 'Windows':
slash = '\\'
else:
slash = '/'
if not s.endswith(slash):
s = s + slash
return s
def uri_validator(x):
from urllib.parse import urlsplit
try:

Loading…
Cancel
Save