Skip to content

Commit f8bbcea

Browse files
authored
Merge pull request harelba#143 from harelba/v1.6.0-release-test
V1.6.2 stuff
2 parents cfe2d04 + 94bae32 commit f8bbcea

File tree

10 files changed

+234
-35
lines changed

10 files changed

+234
-35
lines changed

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ rpm_build_area
88
setup.exe
99
win_output
1010
win_build
11+
packages
12+
.idea/

‎bin/q‎

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#
2828
# Run with --help for command line details
2929
#
30-
q_version="1.6.0notreleasedyet"
30+
q_version="1.6.0"
3131

3232
__all__= [ 'QTextAsData' ]
3333

@@ -50,8 +50,6 @@ import uuid
5050
importcStringIO
5151
importmath
5252

53-
csv.field_size_limit(sys.maxsize)
54-
5553
DEBUG=False
5654

5755
defget_stdout_encoding(encoding_override=None):
@@ -210,6 +208,14 @@ class CouldNotConvertStringToNumericValueException(Exception):
210208
def__str(self):
211209
returnrepr(self.msg)
212210

211+
classColumnMaxLengthLimitExceededException(Exception):
212+
213+
def__init__(self, msg):
214+
self.msg=msg
215+
216+
def__str(self):
217+
returnrepr(self.msg)
218+
213219
classCouldNotParseInputException(Exception):
214220

215221
def__init__(self, msg):
@@ -636,6 +642,11 @@ def encoded_csv_reader(encoding, f, dialect, **kwargs):
636642
raiseCouldNotConvertStringToNumericValueException(e.message)
637643
else:
638644
raiseCouldNotParseInputException(str(e))
645+
exceptException,e:
646+
ifstr(e).startswith("field larger than field limit"):
647+
raiseColumnMaxLengthLimitExceededException(str(e))
648+
else:
649+
raise
639650

640651
defnormalized_filename(filename):
641652
iffilename=='-':
@@ -671,9 +682,13 @@ class MaterializedFileState(object):
671682
exceptException,e:
672683
raiseException('Tried to skip BOM for "utf-8-sig" encoding and failed. Error message is '+str(e))
673684
csv_reader=encoded_csv_reader(self.encoding, self.f, dialect=self.dialect)
674-
forcol_valsincsv_reader:
675-
self.lines_read+=1
676-
yieldcol_vals
685+
try:
686+
forcol_valsincsv_reader:
687+
self.lines_read+=1
688+
yieldcol_vals
689+
exceptColumnMaxLengthLimitExceededException,e:
690+
msg="Column length is larger than the maximum. Offending file is '%s' - Line is %s, counting from 1 (encoding %s). The line number is the raw line number of the file, ignoring whether there's a header or not"% (self.filename,self.lines_read+1,self.encoding)
691+
raiseColumnMaxLengthLimitExceededException(msg)
677692

678693
defclose(self):
679694
ifself.f!=sys.stdin:
@@ -1079,7 +1094,8 @@ class QInputParams(object):
10791094
expected_column_count=None,keep_leading_whitespace_in_values=False,
10801095
disable_double_double_quoting=False,disable_escaped_double_quoting=False,
10811096
disable_column_type_detection=False,
1082-
input_quoting_mode='minimal',stdin_file=None,stdin_filename='-'):
1097+
input_quoting_mode='minimal',stdin_file=None,stdin_filename='-',
1098+
max_column_length_limit=131072):
10831099
self.skip_header=skip_header
10841100
self.delimiter=delimiter
10851101
self.input_encoding=input_encoding
@@ -1091,6 +1107,7 @@ class QInputParams(object):
10911107
self.disable_escaped_double_quoting=disable_escaped_double_quoting
10921108
self.input_quoting_mode=input_quoting_mode
10931109
self.disable_column_type_detection=disable_column_type_detection
1110+
self.max_column_length_limit=max_column_length_limit
10941111

10951112
defmerged_with(self,input_params):
10961113
params=QInputParams(**self.__dict__)
@@ -1113,7 +1130,6 @@ class QTextAsData(object):
11131130
# Create DB object
11141131
self.db=Sqlite3DB()
11151132

1116-
11171133
input_quoting_modes={'minimal' : csv.QUOTE_MINIMAL,
11181134
'all' : csv.QUOTE_ALL,
11191135
# nonnumeric is not supported for input quoting modes, since we determine the data types
@@ -1149,6 +1165,8 @@ class QTextAsData(object):
11491165
dialect_id=self.get_dialect_id(filename)
11501166
csv.register_dialect(dialect_id, **q_dialect)
11511167

1168+
csv.field_size_limit(input_params.max_column_length_limit)
1169+
11521170
# Create a line splitter
11531171
line_splitter=LineSplitter(input_params.delimiter, input_params.expected_column_count)
11541172

@@ -1261,6 +1279,8 @@ class QTextAsData(object):
12611279
error=QError(e,"Could not convert string to a numeric value. Did you use `-w nonnumeric` with unquoted string values? Error: %s"%e.msg,58)
12621280
exceptCouldNotParseInputException,e:
12631281
error=QError(e,"Could not parse the input. Please make sure to set the proper -w input-wrapping parameter for your input, and that you use the proper input encoding (-e). Error: %s"%e.msg,59)
1282+
exceptColumnMaxLengthLimitExceededException,e:
1283+
error=QError(e,e.msg,31)
12641284
exceptKeyboardInterrupt,e:
12651285
warnings.append(QWarning(e,"Interrupted"))
12661286
exceptException, e:
@@ -1530,6 +1550,8 @@ def run_standalone():
15301550
#-----------------------------------------------
15311551
parser.add_option("-v", "--version", dest="version", default=False, action="store_true",
15321552
help="Print version")
1553+
parser.add_option("-V", "--verbose", dest="verbose", default=False, action="store_true",
1554+
help="Print debug info in case of problems")
15331555
#-----------------------------------------------
15341556
input_data_option_group=OptionGroup(parser,"Input Data Options")
15351557
input_data_option_group.add_option("-H", "--skip-header", dest="skip_header", default=default_skip_header, action="store_true",
@@ -1558,6 +1580,8 @@ def run_standalone():
15581580
help="Don't detect column types - All columns will be treated as text columns")
15591581
input_data_option_group.add_option("-w","--input-quoting-mode",dest="input_quoting_mode",default="minimal",
15601582
help="Input quoting mode. Possible values are all, minimal and none. Note the slightly misleading parameter name, and see the matching -W parameter for output quoting.")
1583+
input_data_option_group.add_option("-M","--max-column-length-limit",dest="max_column_length_limit",default=131072,
1584+
help="Sets the maximum column length.")
15611585
parser.add_option_group(input_data_option_group)
15621586
#-----------------------------------------------
15631587
output_data_option_group=OptionGroup(parser,"Output Options")
@@ -1681,6 +1705,14 @@ def run_standalone():
16811705
# (since no input delimiter means any whitespace)
16821706
options.output_delimiter=" "
16831707

1708+
try:
1709+
max_column_length_limit=int(options.max_column_length_limit)
1710+
ifmax_column_length_limit<1:
1711+
raiseException()
1712+
except:
1713+
print>>sys.stderr, "Max column length limit must be a positive integer (%s)"%max_column_length_limit
1714+
sys.exit(31)
1715+
16841716
default_input_params=QInputParams(skip_header=options.skip_header,
16851717
delimiter=options.delimiter,
16861718
input_encoding=options.encoding,
@@ -1691,7 +1723,8 @@ def run_standalone():
16911723
disable_double_double_quoting=options.disable_double_double_quoting,
16921724
disable_escaped_double_quoting=options.disable_escaped_double_quoting,
16931725
input_quoting_mode=options.input_quoting_mode,
1694-
disable_column_type_detection=options.disable_column_type_detection)
1726+
disable_column_type_detection=options.disable_column_type_detection,
1727+
max_column_length_limit=max_column_length_limit)
16951728
q_engine=QTextAsData(default_input_params=default_input_params)
16961729

16971730
output_params=QOutputParams(
@@ -1700,7 +1733,7 @@ def run_standalone():
17001733
output_quoting_mode=options.output_quoting_mode,
17011734
formatting=options.formatting,
17021735
output_header=options.output_header)
1703-
q_output_printer=QOutputPrinter(output_params,show_tracebacks=DEBUG)
1736+
q_output_printer=QOutputPrinter(output_params,show_tracebacks=options.verbose)
17041737

17051738
forquery_strinquery_strs:
17061739
ifoptions.analyze_only:

‎build-deb-builder-container‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
if [ $#-ne 1 ];
4+
then
5+
echo"Usage: $(basename $0) <version-tag>"
6+
exit 1
7+
fi
8+
VERSION_TAG="$1"
9+
10+
docker build -f dist/deb-builder-Dockerfile -t q-text-as-data-deb-builder:${VERSION_TAG}.

‎build-rpm-builder-container‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
if [ $#-ne 1 ];
4+
then
5+
echo"Usage: $(basename $0) <version-tag>"
6+
exit 1
7+
fi
8+
VERSION_TAG="$1"
9+
10+
docker build -f dist/rpm-builder-Dockerfile -t q-text-as-data-rpm-builder:${VERSION_TAG}.

‎dist/create-rpm‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#
66
#
77

8-
if [ $#-ne2 ];
8+
if [ $#-ne1 ];
99
then
10-
echo'create-rpm <commit-hash> <version>'
10+
echo'create-rpm <version>'
1111
exit 1
1212
fi
1313

@@ -26,9 +26,7 @@ mkdir -p ${rpm_build_area}/{SOURCES,SPECS,BUILD,RPMS,SRPMS,BUILDROOT}
2626

2727
echo RPM build area is in${rpm_build_area}
2828

29-
COMMIT_HASH=$1
30-
SHORT_HASH=${COMMIT_HASH:0:7}
31-
VERSION=$2
29+
VERSION=$1
3230
REAL_PACKAGE_NAME=q
3331
RPM_PACKAGE_NAME=q-text-as-data
3432

@@ -40,11 +38,15 @@ then
4038
exit 1
4139
fi
4240

43-
rm -vf ${rpm_build_area}/SOURCES/q-${COMMIT_HASH}.tar.gz
44-
45-
curl -o ${rpm_build_area}/SOURCES/q-${COMMIT_HASH}.tar.gz -L -R "https://github.com/harelba/q/tarball/${COMMIT_HASH}"
41+
curl -o ${rpm_build_area}/SOURCES/q.tar.gz -L -R "https://github.com/harelba/q/tarball/${VERSION}"
42+
mkdir -p ${rpm_build_area}/SOURCES
43+
pushd${rpm_build_area}/SOURCES >/dev/null
44+
tar xvzf ./q.tar.gz --strip-components=1
45+
rm -vf ./q.tar.gz
46+
popd>/dev/null
47+
find ${rpm_build_area}/ -ls
4648

47-
cat ${RPM_PACKAGE_NAME}.spec.template | sed "s/VERSION_PLACEHOLDER/$VERSION/g"| sed "s/COMMIT_HASH_PLACEHOLDER/${COMMIT_HASH}/g"| sed "s/SHORT_HASH_PLACEHOLDER/${SHORT_HASH}/g">${rpm_build_area}/SPECS/${RPM_PACKAGE_NAME}.spec
49+
cat ${RPM_PACKAGE_NAME}.spec.template | sed "s/VERSION_PLACEHOLDER/$VERSION/g">${rpm_build_area}/SPECS/${RPM_PACKAGE_NAME}.spec
4850

4951
rpmbuild -v --define "_topdir ${rpm_build_area}" -ba ${rpm_build_area}/SPECS/${RPM_PACKAGE_NAME}.spec
5052

‎dist/deb-builder-Dockerfile‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
FROM ubuntu:12.04
3+
4+
RUN apt-get update && apt-get install -y alien
5+
6+
ENTRYPOINT "/bin/bash"
7+
8+

‎dist/q-text-as-data.spec.template‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@ Summary: q - Text as Data
1010
Group: Applications/Text
1111
License: GPLv3
1212
URL: https://github.com/harelba/q
13-
Source: q-COMMIT_HASH_PLACEHOLDER.tar.gz
1413
BuildArch: noarch
1514

1615
%description
1716
q allows to perform SQL-like statements on tabular text data.
1817

1918

2019
%prep
21-
%setup -qn harelba-q-SHORT_HASH_PLACEHOLDER
20+
cd %{_topdir}/BUILD
21+
cp -vrf %{_topdir}/SOURCES/* %{_topdir}/BUILD/
22+
chmod -Rf a+rX,u+w,g-w,o-w %{_topdir}/BUILD/
2223

2324
%build
24-
ls -ltr
25+
cd %{_topdir}/BUILD
2526
ronn doc/USAGE.markdown
2627

2728
%install
@@ -43,6 +44,9 @@ gzip ${RPM_BUILD_ROOT}%{_mandir}/man1/q.1
4344
%doc %_mandir/man1/q.1.gz
4445

4546
%changelog
47+
*Wed Apr 05 2017 Harel Ben-Attia <[email protected]> 1.6.0-1
48+
- Moved RPM building to be dockerized
49+
- Removed the need for providing commit hashes
4650
*Fri Dec 12 2014 Harel Ben-Attia <[email protected]> 1.5.0-1
4751
- Moved stuff from create-rpm script into the rpm spec itself
4852
*Sat Jun 14 2014 Harel Ben-Attia <[email protected]> 1.4.0-1

‎dist/rpm-builder-Dockerfile‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
FROM centos:centos6
3+
4+
RUN yum install -y which curl gcc make rpm rpm-build
5+
6+
RUN curl -sSL https://get.rvm.io | bash
7+
8+
RUN /bin/bash -l -c "rvm install 2.4.1" && /bin/bash -l -c "gem install ronn"
9+
10+
ENTRYPOINT "/bin/bash"
11+
12+

‎package-release‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
base_folder=$(dirname $0)
6+
pushd${base_folder}>/dev/null
7+
8+
if [ $#-ne 1 ];
9+
then
10+
echo"Usage: $(dirname $0) <git-tag>"
11+
echo
12+
echo"Note that the git tag must be pushed to github before doing this."
13+
exit 1
14+
fi
15+
TAG="$1"
16+
17+
d=`pwd`
18+
cid1=`docker run -i -d -v ${d}:/q q-text-as-data-rpm-builder:0.1`
19+
cid2=`docker run -i -d -v ${d}:/q q-text-as-data-deb-builder:0.1`
20+
21+
functionkill_container{
22+
tmp=`docker kill${cid1}${cid2}`
23+
}
24+
trap kill_container EXIT
25+
26+
rm -rvf ${base_folder}/packages
27+
mkdir -p ${base_folder}/packages
28+
29+
sleep 1
30+
docker exec -it ${cid1} /bin/bash -i -c "/q/dist/create-rpm ${TAG}"
31+
32+
docker cp ${cid1}:/q/dist/rpm_build_area/RPMS/noarch/q-text-as-data-${TAG}-1.el6.noarch.rpm ${base_folder}/packages/q-text-as-data-${TAG}-1.noarch.rpm
33+
34+
docker exec -it ${cid2} /bin/bash -i -c "cd /q/packages && alien ./q-text-as-data-${TAG}-1.noarch.rpm"
35+

0 commit comments

Comments
(0)