Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyOTRS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Som Connexió
OTRS
PyOTRS
Commits
f26b97ef
Commit
f26b97ef
authored
7 years ago
by
Robert Habermann
Browse files
Options
Downloads
Patches
Plain Diff
add store attachment feature to cli
parent
f17468ab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cli/PyOTRS.py
+23
-3
23 additions, 3 deletions
cli/PyOTRS.py
with
23 additions
and
3 deletions
cli/PyOTRS.py
+
23
−
3
View file @
f26b97ef
...
...
@@ -4,6 +4,7 @@
import
os
import
stat
import
click
import
tempfile
from
pyotrs.version
import
__version__
from
pyotrs.lib
import
Client
...
...
@@ -73,6 +74,10 @@ def cli(config_file=None):
help
=
'
include Articles
'
)
@click.option
(
'
--attachments
'
,
is_flag
=
True
,
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
,
envvar
=
'
PYOTRS_TICKET_ID
'
,
help
=
'
Ticket ID
'
)
...
...
@@ -87,7 +92,8 @@ def cli(config_file=None):
help
=
'
Base URL
'
)
@cli.command
(
name
=
"
get
"
)
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
):
"""
PyOTRS get command
"""
click
.
secho
(
"
Connecting to %s as %s..
"
%
(
baseurl
,
username
))
...
...
@@ -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
(
"
Priority:
\t
%s
"
%
ticket
.
field_get
(
"
Priority
"
))
click
.
secho
(
"
\n
Full Ticket:
"
)
print
(
ticket
.
to_dct
())
if
store_attachments
:
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
(
"
\n
storing 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())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment