Skip to content

Commit

Permalink
Merge pull request #342 from Harshetjain666/unreleased
Browse files Browse the repository at this point in the history
Add support for python 3.12 version
  • Loading branch information
Harshetjain666 authored Feb 19, 2025
2 parents 3c6a34c + dbf2028 commit ed9f4ab
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion example/qubole_presto_api_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ConfigParser import SafeConfigParser
from qds_sdk.qubole import Qubole
from qds_sdk.commands import *
import boto
import boto3
import time


Expand Down
30 changes: 15 additions & 15 deletions qds_sdk/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from qds_sdk.util import GentleOptionParser, OptionParsingError, OptionParsingExit, _is_cloud_url
from optparse import SUPPRESS_HELP

import boto
import boto3
import time
import logging
import sys
Expand Down Expand Up @@ -299,12 +299,12 @@ def get_results(self, fp=sys.stdout, inline=True, delim=None, fetch=True, qlog=N
pass
else:
if fetch:
if not boto.config.has_section('s3'):
boto.config.add_section('s3')
boto.config.set('s3', 'use-sigv4', 'True')
if not boto3.config.has_section('s3'):
boto3.config.add_section('s3')
boto3.config.set('s3', 'use-sigv4', 'True')
storage_credentials = conn.get(Account.credentials_rest_entity_path)
host = storage_credentials['region_endpoint'] if storage_credentials['region_endpoint'] else "s3.amazonaws.com"
boto_conn = boto.connect_s3(aws_access_key_id=storage_credentials['storage_access_key'],
boto3_conn = boto3.connect_s3(aws_access_key_id=storage_credentials['storage_access_key'],
aws_secret_access_key=storage_credentials['storage_secret_key'],
security_token=storage_credentials['session_token'],
host=host)
Expand All @@ -320,11 +320,11 @@ def get_results(self, fp=sys.stdout, inline=True, delim=None, fetch=True, qlog=N

# In Python 3,
# If the delim is None, fp should be in binary mode because
# boto expects it to be.
# boto3 expects it to be.
# If the delim is not None, then both text and binary modes
# work.

_download_to_local(boto_conn, s3_path, fp, num_result_dir, delim=delim)
_download_to_local(boto3_conn, s3_path, fp, num_result_dir, delim=delim)
else:
fp.write(",".join(r['result_location']))

Expand Down Expand Up @@ -1121,7 +1121,7 @@ def parse(cls, args):
raise ParseError("dbtap_id and db_table are required",
cls.optparser.format_help())

if options.mode is "1":
if options.mode == "1":
if options.hive_table is None:
raise ParseError("hive_table is required for mode 1",
cls.optparser.format_help())
Expand All @@ -1134,7 +1134,7 @@ def parse(cls, args):
raise ParseError("db_update_mode should either be left blank for append "
"mode or be 'updateonly' or 'allowinsert'",
cls.optparser.format_help())
if options.db_update_mode is "updateonly":
if options.db_update_mode == "updateonly":
if options.db_update_keys is None:
raise ParseError("db_update_keys is required when db_update_mode "
"is 'updateonly'",
Expand Down Expand Up @@ -1501,12 +1501,12 @@ def write_headers(qlog,fp):
fp.write(col_names.encode())


def _download_to_local(boto_conn, s3_path, fp, num_result_dir, delim=None):
def _download_to_local(boto3_conn, s3_path, fp, num_result_dir, delim=None):
'''
Downloads the contents of all objects in s3_path into fp
Args:
`boto_conn`: S3 connection object
`boto3_conn`: S3 connection object
`s3_path`: S3 path to be downloaded
Expand All @@ -1521,15 +1521,15 @@ def _callback(downloaded, total):
`total`: Total file size to be downloaded (int)
'''
if (total is 0) or (downloaded == total):
if (total == 0) or (downloaded == total):
return
progress = downloaded*100/total
sys.stderr.write('\r[{0}] {1}%'.format('#'*progress, progress))
sys.stderr.flush()

m = _URI_RE.match(s3_path)
bucket_name = m.group(1)
bucket = boto_conn.get_bucket(bucket_name)
bucket = boto3_conn.get_bucket(bucket_name)
retries = 6
if s3_path.endswith('/') is False:
#It is a file
Expand All @@ -1546,9 +1546,9 @@ def _callback(downloaded, total):
if delim is None:
try:
key_instance.get_contents_to_file(fp) # cb=_callback
except boto.exception.S3ResponseError as e:
except boto3.exception.S3ResponseError as e:
if (e.status == 403):
# SDK-191, boto gives an error while fetching the objects using versions which happens by default
# SDK-191, boto3 gives an error while fetching the objects using versions which happens by default
# in the get_contents_to_file() api. So attempt one without specifying version.
log.warn("Access denied while fetching the s3 object. Retrying without specifying the version....")
key_instance.open()
Expand Down
4 changes: 2 additions & 2 deletions qds_sdk/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def parsers():
create = subparsers.add_parser("create", help="Create a new Role")
create.add_argument("--name", dest="name", required=True, help="Name of the new Role")
create.add_argument("--policy", dest="policy", required=True,
help="Policy Statement example '[{\"access\":\"deny\", \"resource\": \"all\", \"action\": \"[\"create\",\"update\",\"delete\"\]\"}]'")
help="Policy Statement example '[{\"access\":\"deny\", \"resource\": \"all\", \"action\": \"[\"create\",\"update\",\"delete\"]\"}]'")
create.set_defaults(func=RoleCmdLine.create)

#List
Expand All @@ -39,7 +39,7 @@ def parsers():
update.add_argument("id", help="Numeric id of the Role")
update.add_argument("--name", dest="name", help="New name of the Role")
update.add_argument("--policy", dest="policy",
help="Policy Statement example '[{\"access\":\"deny\", \"resource\": \"all\", \"action\": \"[\"create\",\"update\",\"delete\"\]\"}]'")
help="Policy Statement example '[{\"access\":\"deny\", \"resource\": \"all\", \"action\": \"[\"create\",\"update\",\"delete\"]\"}]'")
update.set_defaults(func=RoleCmdLine.update)

#Delete
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
boto==2.45.0
boto3==1.15.0
certifi==2019.6.16
chardet==3.0.4
idna==2.8
Expand Down
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
from setuptools import setup

INSTALL_REQUIRES = ['requests >=2.21.0', 'boto >=2.45.0', 'six >=1.12.0',
INSTALL_REQUIRES = ['requests >=2.21.0', 'boto3 >=1.15.0', 'six >=1.12.0',
'urllib3 >= 1.24.3']
if sys.version_info < (2, 7, 0):
INSTALL_REQUIRES.append('argparse>=1.1')
Expand All @@ -17,7 +17,7 @@ def read(fname):

setup(
name="qds_sdk",
version="1.13.2",
version="1.13.3",
author="Qubole",
author_email="[email protected]",
description=("Python SDK for coding to the Qubole Data Service API"),
Expand All @@ -38,6 +38,9 @@ def read(fname):
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4"
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12"
]
)

0 comments on commit ed9f4ab

Please sign in to comment.