#!/usr/bin/python -OO
# This file is part of Archivematica.
#
# Copyright 2010-2012 Artefactual Systems Inc.
#
# Archivematica is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Archivematica is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Archivematica. If not, see .
# @package Archivematica
# @subpackage testing
# @author Joseph Perry
import sys
import os
import shlex
import subprocess
fix = True
if __name__ == '__main__':
print sys.stdout.encoding
print __file__
print u'\u2019'.encode('utf-8'),
print u'\u2019'
i = 0
if len(sys.argv) != 2:
i = 0
else:
i = int(sys.argv[1]) + 1
command = "%s %d" % (__file__, i)
print i
if i < 10:
my_env = os.environ
if fix:
my_env['PYTHONIOENCODING'] = 'utf-8'
#for key, value in my_env.iteritems():
# print key, ":\t", value
stdIn = None
p = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, env=my_env)
stdOut, stdError = p.communicate(input=stdIn)
print stdOut
print >>sys.stderr, stdError