Skip to content
Snippets Groups Projects
Commit 0d2f8682 authored by Robert Habermann's avatar Robert Habermann
Browse files

merge

parents a4bf32b1 b3542c26
No related branches found
No related tags found
No related merge requests found
...@@ -13,10 +13,14 @@ This project adheres to [Semantic Versioning](http://semver.org/). ...@@ -13,10 +13,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
0.2.0 - planned first release 0.2.0 - planned first release
----------------------------- -----------------------------
0.1.23 - 2017-xx-yy (unreleased) 0.1.24 - 2017-xx-yy (unreleased)
-------------------------------- --------------------------------
- -
0.1.23 - 2017-05-17
-------------------
- add store attachment feature to cli
0.1.22 - 2017-03-04 0.1.22 - 2017-03-04
-------------------------------- --------------------------------
- completed FAQ API - completed FAQ API
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import os import os
import stat import stat
import click import click
import tempfile
from pyotrs.version import __version__ from pyotrs.version import __version__
from pyotrs.lib import Client from pyotrs.lib import Client
...@@ -73,6 +74,10 @@ def cli(config_file=None): ...@@ -73,6 +74,10 @@ def cli(config_file=None):
help='include Articles') help='include Articles')
@click.option('--attachments', is_flag=True, @click.option('--attachments', is_flag=True,
help='include Article Attachments') help='include Article Attachments')
@click.option('--store-attachments', is_flag=True,
help='store Article Attachments to /tmp/<ticket_id>')
@click.option('--store-path', type=click.STRING,
help='where to store Attachments (default: /tmp/pyotrs_<random_str>')
@click.option('-t', '--ticket-id', type=click.INT, prompt=True, @click.option('-t', '--ticket-id', type=click.INT, prompt=True,
envvar='PYOTRS_TICKET_ID', envvar='PYOTRS_TICKET_ID',
help='Ticket ID') help='Ticket ID')
...@@ -87,7 +92,8 @@ def cli(config_file=None): ...@@ -87,7 +92,8 @@ def cli(config_file=None):
help='Base URL') help='Base URL')
@cli.command(name="get") @cli.command(name="get")
def get(baseurl=None, username=None, password=None, ticket_id=None, def get(baseurl=None, username=None, password=None, ticket_id=None,
articles=False, attachments=False, articles=False,
attachments=False, store_attachments=False, store_path=None,
https_verify=True, ca_cert_bundle=None): https_verify=True, ca_cert_bundle=None):
"""PyOTRS get command""" """PyOTRS get command"""
click.secho("Connecting to %s as %s.." % (baseurl, username)) click.secho("Connecting to %s as %s.." % (baseurl, username))
...@@ -103,5 +109,19 @@ def get(baseurl=None, username=None, password=None, ticket_id=None, ...@@ -103,5 +109,19 @@ def get(baseurl=None, username=None, password=None, ticket_id=None,
click.secho("State: \t\t%s" % ticket.field_get("State")) click.secho("State: \t\t%s" % ticket.field_get("State"))
click.secho("Priority: \t%s" % ticket.field_get("Priority")) click.secho("Priority: \t%s" % ticket.field_get("Priority"))
click.secho("\nFull Ticket:") if store_attachments:
print(ticket.to_dct()) if store_path:
store_path = store_path
if not os.path.exists(store_path):
os.makedirs(store_path)
else:
store_path = tempfile.mkdtemp(prefix="pyotrs_")
click.secho("\nstoring attachments to: %s" % store_path)
for article in ticket.articles:
for attachment in article.attachments:
attachment.save_to_dir(folder=store_path)
click.secho("%s stored." % attachment)
# click.secho("\nFull Ticket:")
# print(ticket.to_dct())
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
# 3) we can import it into your module module # 3) we can import it into your module module
""" """
__version_info__ = ('0', '1', '22') __version_info__ = ('0', '1', '23')
__version__ = '.'.join(__version_info__) __version__ = '.'.join(__version_info__)
...@@ -34,7 +34,6 @@ pycallgraph==1.0.1 ...@@ -34,7 +34,6 @@ pycallgraph==1.0.1
pycodestyle==2.3.1 pycodestyle==2.3.1
pyflakes==1.5.0 pyflakes==1.5.0
Pygments==2.2.0 Pygments==2.2.0
-e git+git@gitlab.com:/rhab/PyOTRS@480a86f37ed35d8658ce86de83047082c52a4a8f#egg=PyOTRS
pyparsing==2.1.10 pyparsing==2.1.10
pytest==3.0.6 pytest==3.0.6
pytest-cov==2.4.0 pytest-cov==2.4.0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment