Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Cmd2 command-line parsing methods have changed #32

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
language: python
cache: pip
dist: xenial
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"

install:
- "pip install ."
- "pip install -r requirements.txt"
- "pip install ."

script: nosetests
1 change: 1 addition & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Athena CLI
Copyright 2017-2018 Guardian News & Media
Copyright 2019 Nick Satterly

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ License

Athena CLI
Copyright 2017-2018 Guardian News & Media
Copyright 2019 Nick Satterly

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
15 changes: 5 additions & 10 deletions athena_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ def execute(self, statement):

if status == 'SUCCEEDED':
results = self.athena.get_query_results(execution_id)
headers = [h['Name'].encode("utf-8") for h in results['ResultSet']['ResultSetMetadata']['ColumnInfo']]
headers = [h['Name'] for h in results['ResultSet']['ResultSetMetadata']['ColumnInfo']]

if self.format in ['CSV', 'CSV_HEADER']:
csv_writer = csv.writer(sys.stdout, quoting=csv.QUOTE_ALL)
if self.format == 'CSV_HEADER':
csv_writer.writerow(headers)
csv_writer.writerows([[text.encode("utf-8") for text in row] for row in self.athena.yield_rows(results, headers)])
csv_writer.writerows([row for row in self.athena.yield_rows(results, headers)])
elif self.format == 'TSV':
print(tabulate([row for row in self.athena.yield_rows(results, headers)], tablefmt='tsv'))
elif self.format == 'TSV_HEADER':
Expand All @@ -64,12 +64,6 @@ def execute(self, statement):
if status == 'FAILED':
print(stats['QueryExecution']['Status']['StateChangeReason'])

try:
del cmd.Cmd.do_show # "show" is an Athena command
except AttributeError:
# "show" was removed from Cmd2 0.8.0
pass


class AthenaShell(cmd.Cmd, object):

Expand Down Expand Up @@ -179,7 +173,7 @@ def do_set(self, arg):
super(AthenaShell, self).do_set(arg)

def default(self, line):
self.execution_id = self.athena.start_query_execution(self.dbname, line.full_parsed_statement())
self.execution_id = self.athena.start_query_execution(self.dbname, line.command_and_args)
if not self.execution_id:
return

Expand Down Expand Up @@ -349,8 +343,9 @@ def main():
)
parser.add_argument(
'--output-format',
choices=('ALIGNED', 'VERTICAL', 'CSV', 'TSV', 'CSV_HEADER', 'TSV_HEADER', 'NULL'),
dest='format',
help='output format for batch mode [ALIGNED, VERTICAL, CSV, TSV, CSV_HEADER, TSV_HEADER, NULL]'
help='output format for batch mode'
)
parser.add_argument(
'--schema',
Expand Down
7 changes: 0 additions & 7 deletions pypi.md

This file was deleted.

6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
boto3
cmd2
tabulate>=0.8.1
boto3==1.9.145
cmd2==0.9.12
tabulate==0.8.3
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
name="athena-cli",
version=version,
description='Presto-like CLI for AWS Athena',
url='https://github.com/guardian/athena-cli',
url='https://github.com/satterly/athena-cli',
license='Apache License 2.0',
author='Nick Satterly',
author_email='nick.satterly@theguardian.com',
author_email='nick.satterly@gmail.com',
packages=find_packages(),
py_modules=[
'athena_cli'
],
install_requires=[
'boto3',
'cmd2',
'cmd2>=0.9.0.1',
'tabulate>=0.8.1'
],
include_package_data=True,
Expand All @@ -30,5 +30,6 @@
keywords='aws athena presto cli',
classifiers=[
'Topic :: Utilities'
]
],
python_requires='>=3.5'
)