From 7999ca657997e78febfb3fb89cfcc066d50bf788 Mon Sep 17 00:00:00 2001 From: Noah Spurrier Date: Fri, 26 Oct 2012 11:19:10 -0700 Subject: Moved everything up one directory level. --- tools/dotfiles.tar.gz | Bin 0 -> 292124 bytes tools/getkey.py | 46 ++++++++++++ tools/merge_templates.py | 57 +++++++++++++++ tools/pyed.py | 180 +++++++++++++++++++++++++++++++++++++++++++++++ tools/sfupload.py | 46 ++++++++++++ tools/step.py | 47 +++++++++++++ tools/testall.py | 78 ++++++++++++++++++++ tools/testsweep.py | 72 +++++++++++++++++++ tools/tweak_files.py | 45 ++++++++++++ tools/websync.py | 63 +++++++++++++++++ 10 files changed, 634 insertions(+) create mode 100644 tools/dotfiles.tar.gz create mode 100755 tools/getkey.py create mode 100755 tools/merge_templates.py create mode 100755 tools/pyed.py create mode 100755 tools/sfupload.py create mode 100755 tools/step.py create mode 100755 tools/testall.py create mode 100755 tools/testsweep.py create mode 100755 tools/tweak_files.py create mode 100755 tools/websync.py (limited to 'tools') diff --git a/tools/dotfiles.tar.gz b/tools/dotfiles.tar.gz new file mode 100644 index 0000000..0636410 Binary files /dev/null and b/tools/dotfiles.tar.gz differ diff --git a/tools/getkey.py b/tools/getkey.py new file mode 100755 index 0000000..76c07de --- /dev/null +++ b/tools/getkey.py @@ -0,0 +1,46 @@ +''' +This currently just holds some notes. +This is not expected to be working code. + +$Revision: 120 $ +$Date: 2002-11-27 11:13:04 -0800 (Wed, 27 Nov 2002) $ + +PEXPECT LICENSE + + This license is approved by the OSI and FSF as GPL-compatible. + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2012, Noah Spurrier + PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY + PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE + COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +''' + +import tty, termios, sys + +def getkey(): + file = sys.stdin.fileno() + mode = termios.tcgetattr(file) + try: + tty.setraw(file, termios.TCSANOW) + ch = sys.stdin.read(1) + finally: + termios.tcsetattr(file, termios.TCSANOW, mode) + return ch + +def test_typing (): + s = screen (10,10) + while 1: + ch = getkey() + s.type(ch) + print str(s) + print + diff --git a/tools/merge_templates.py b/tools/merge_templates.py new file mode 100755 index 0000000..accc8e9 --- /dev/null +++ b/tools/merge_templates.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python + +''' +I used to use this to keep the sourceforge pages up to date with the +latest documentation and I like to keep a copy of the distribution +on the web site so that it will be compatible with +The Vaults of Parnasus which requires a direct URL link to a +tar ball distribution. I don't advertise the package this way. + +PEXPECT LICENSE + + This license is approved by the OSI and FSF as GPL-compatible. + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2012, Noah Spurrier + PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY + PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE + COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +''' +import sys, os, re +import pyed +try: + import pexpect +except: + # this happens if Pexpect was never installed to begin with. + sys.path.insert(0, '.') + import pexpect + +# extract the version number from the pexpect.py source. +d = pyed.pyed() +d.read ("pexpect.py") +d.first('^__version__') +r = re.search("'([0-9]\.[0-9])'", d.cur_line) +version = r.group(1) + +# Edit the index.html to update current VERSION. +d = pyed.pyed() +d.read ("doc/index.template.html") +for cl in d.match_lines('.*VERSION.*'): + d.cur_line = d.cur_line.replace('VERSION', version) +d.write("doc/index.html") + +# Edit the setup.py to update current VERSION. +d = pyed.pyed() +d.read ("setup.py.template") +for cl in d.match_lines('.*VERSION.*'): + d.cur_line = d.cur_line.replace('VERSION', version) +d.write("setup.py") +os.chmod("setup.py", 0755) + diff --git a/tools/pyed.py b/tools/pyed.py new file mode 100755 index 0000000..14c562a --- /dev/null +++ b/tools/pyed.py @@ -0,0 +1,180 @@ +"""This represents a document with methods to allow easy editing. +Think 'sed', only more fun to use. +Example 1: Convert all python-style comments in a file to UPPERCASE. +This operates as a filter on stdin, so this needs a shell pipe. +cat myscript.py | upper_filter.py + import sys, pyed + pe = pyed() + pe.read(sys.stdin) + for pe in pe.match_lines('^\\s*#'): + pe.cur_line = pe.cur_line.upper() + print pe + +Example 2: Edit an Apache2 httpd.conf file to turn on supplemental SSL configuration. + import pyed + pe = pyed() + pe.read("httpd.conf") + pe.first('#Include conf/extra/httpd-ssl.conf') + pe.cur_line = 'Include conf/extra/httpd-ssl.conf' + pe.write("httpd.conf") + +PEXPECT LICENSE + + This license is approved by the OSI and FSF as GPL-compatible. + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2012, Noah Spurrier + PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY + PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE + COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +""" + +import re +class pyed (object): + def __init__ (self, new_str=None): + if new_str is not None: + self.lines = new_str.splitlines() + self.cur_line_num = 0 + else: + self.lines = None + # force invalid line number + self.cur_line_num = None + def match_lines (self, pattern, beg=0, end=None): + """This returns a generator that iterates this object + over the lines and yielding when a line matches the pattern. + Note that this generator mutates this object so that + the cur_line is changed to the line matching the pattern. + """ + p = re.compile (pattern) + if end is None: + end = len(self.lines) + for i in xrange (beg,end): + m = p.match(self.lines[i]) + if m is not None: + self.cur_line_num = i + yield self + else: + # force invalid line number + cur_line_num = None + def match_lines_rev (self, pattern, beg=0, end=None): + """This is similar to match_lines, but the order is reversed. + """ + p = re.compile (pattern) + if end is None: + end = len(self.lines) + for i in xrange (end-1,beg-1,-1): + m = p.match(self.lines[i]) + if m is not None: + self.cur_line_num = i + yield self + else: + # force invalid line number + cur_line_num = None + def next (self): + self.cur_line_num = self.cur_line_num + 1 + if self.cur_line_num >= len(self.lines): + self.cur_line_num = len(self.lines) - 1 + return self.cur_line + def prev (self): + self.cur_line_num = self.cur_line_num - 1 + if self.cur_line_num < 0: + self.cur_line_num = 0 + return self.cur_line + def first (self, pattern=None): + if pattern is not None: + try: + return self.match_lines(pattern).next() + except StopIteration, e: + # force invalid line number + self.cur_line_num = None + return None + self.cur_line_num = 0 + return self.cur_line + def last (self, pattern=None): + if pattern is not None: + try: + return self.match_lines_rev(pattern).next() + except StopIteration, e: + # force invalid line number + self.cur_line_num = None + return None + self.cur_line_num = len(self.lines) - 1 + return self.cur_line + def insert (self, s=''): + """This inserts the string as a new line before the current line number. + """ + self.lines.insert(self.cur_line_num, s) + def append (self, s=''): + """Unlike list append, this appends after the current line number, + not at the end of the entire list. + """ + self.cur_line_num = self.cur_line_num + 1 + self.lines.insert(self.cur_line_num, s) + def delete (self): + del self.cur_line + def read (self, file_holder): + """This reads all the lines from a file. The file_holder may be + either a string filename or any object that supports "read()". + All previous lines are lost. + """ + if hasattr(file_holder, 'read') and callable(file_holder.read): + fin = file_holder + else: + fin = open (file_holder, 'rb') + data = fin.read() + self.lines = data.splitlines() + self.cur_line_num = 0 + def write (self, file_holder): + """This writes all the lines to a file. The file_holder may be + either a string filename or any object that supports "read()". + TODO: Make write be atomic using file move instead of overwrite. + """ + if hasattr(file_holder, 'write') and callable(file_holder.write): + fout = file_holder + else: + fout = open (file_holder, 'wb') + for l in self.lines: + fout.write(l) + fout.write('\n') + # the following are for smart properties. + def __str__ (self): + return '\n'.join(self.lines) + def __get_cur_line (self): + self.__cur_line = self.lines[self.cur_line_num] + return self.__cur_line + def __set_cur_line (self, value): + self.__cur_line = value + self.lines[self.cur_line_num] = self.__cur_line + def __del_cur_line (self): + del self.lines[self.cur_line_num] + if self.cur_line_num >= len(self.lines): + self.cur_line_num = len(self.lines) - 1 + cur_line = property (__get_cur_line, __set_cur_line, __del_cur_line) + # lines = property (get_lines, set_lines, del_lines) + +__NOT_USED =""" +import sys +pe = pyed() +pe.read(sys.stdin) +#print "---" +#print list(x.cur_line for x in pe.match_lines_rev('^#')) +#print pe.first('^#') +#print pe.last('^#') +#print "---" +for pe in pe.match_lines('^\\s*#'): + pe.cur_line = pe.cur_line.lower() +pe.last('# comment.*') +pe.cur_line = '# Comment 1' +print pe +if pe.last('asdfasdf') is None: + print "can't find 'asdfasdf'" +""" + diff --git a/tools/sfupload.py b/tools/sfupload.py new file mode 100755 index 0000000..8a3b078 --- /dev/null +++ b/tools/sfupload.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +'''This uploads the latest pexpect package to sourceforge. + +PEXPECT LICENSE + + This license is approved by the OSI and FSF as GPL-compatible. + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2012, Noah Spurrier + PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY + PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE + COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +''' +import pexpect +import sys + +child = pexpect.spawn('ftp upload.sourceforge.net') +child.logfile = sys.stdout +child.expect('Name .*: ') +child.sendline('anonymous') +child.expect('Password:') +child.sendline('noah@noah.org') +child.expect('ftp> ') +child.sendline('cd /incoming') +child.expect('ftp> ') +child.sendline('lcd dist') +child.expect('ftp> ') +child.sendline('bin') +child.expect('ftp> ') +child.sendline('prompt') +child.expect('ftp> ') +child.sendline('mput pexpect-*.tar.gz') +child.expect('ftp> ') +child.sendline('ls pexpect*') +child.expect('ftp> ') +print child.before +child.sendline('bye') + diff --git a/tools/step.py b/tools/step.py new file mode 100755 index 0000000..cc0062e --- /dev/null +++ b/tools/step.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +''' +# This single steps through a log file. + +PEXPECT LICENSE + + This license is approved by the OSI and FSF as GPL-compatible. + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2012, Noah Spurrier + PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY + PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE + COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +''' + +import tty, termios, sys + +def getkey(): + file = sys.stdin.fileno() + mode = termios.tcgetattr(file) + try: + tty.setraw(file, termios.TCSANOW) + ch = sys.stdin.read(1) + finally: + termios.tcsetattr(file, termios.TCSANOW, mode) + return ch + +fin = open ('log', 'rb') +fout = open ('log2', 'wb') + +while 1: + foo = fin.read(1) + if foo == '': + sys.exit(0) + sys.stdout.write(foo) + getkey() + fout.write (foo) + fout.flush() + diff --git a/tools/testall.py b/tools/testall.py new file mode 100755 index 0000000..28307c7 --- /dev/null +++ b/tools/testall.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +'''This script runs all tests in a directory. +It does not need to know about the tests ahead of time. +It recursively descends from the current directory and +automatically builds up a list of tests to run. +Only directories named 'tests' are processed. +The path to each 'tests' directory is added to the PYTHONPATH. +Only python scripts that start with 'test_' are added to +the list of scripts in the test suite. +Noah Spurrier + +PEXPECT LICENSE + + This license is approved by the OSI and FSF as GPL-compatible. + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2012, Noah Spurrier + PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY + PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE + COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +''' + +import unittest +import os, os.path +import sys + +import pexpect +print "Testing pexpect version:", pexpect.__version__ +print "Testing pexpect revision:", pexpect.__revision__ + +def add_tests_to_list (import_list, dirname, names): + # Only check directories named 'tests'. + if os.path.basename(dirname) != 'tests': + return + # Add any files that start with 'test_' and end with '.py'. + for f in names: + filename, ext = os.path.splitext(f) + if ext != '.py': + continue + if filename.find('test_') == 0: + import_list.append (os.path.join(dirname, filename)) + +def find_modules_and_add_paths (root_path): + import_list = [] + module_list = [] + os.path.walk (root_path, add_tests_to_list, import_list) + for module_file in import_list: + path, module = os.path.split(module_file) + module_list.append (module) + print 'Adding:', module_file + if not path in sys.path: + sys.path.append (path) + if not os.path.dirname(path) in sys.path: + sys.path.append (os.path.dirname(path)) + module_list.sort() + return module_list + +def suite(): + modules_to_test = find_modules_and_add_paths (os.getcwd()) + alltests = unittest.TestSuite() + for module in map(__import__, modules_to_test): + alltests.addTest(unittest.findTestCases(module)) + return alltests + +if __name__ == '__main__': + unittest.main(defaultTest='suite') +# s = all() +# runner = unittest.TextTestRunner() +# runner.run (s) + diff --git a/tools/testsweep.py b/tools/testsweep.py new file mode 100755 index 0000000..0f2c4d5 --- /dev/null +++ b/tools/testsweep.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python +"""This runs testall.py on many different platforms running on the Compile Farm (cf.sourceforge.net). + +PEXPECT LICENSE + + This license is approved by the OSI and FSF as GPL-compatible. + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2012, Noah Spurrier + PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY + PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE + COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +""" +import pexpect +import sys +import getpass + +def test_platform (platform_menu, platform_python_path): + try: + s = pexpect.spawn ('ssh noah@cf.sourceforge.net') + #s.setlog (sys.stdout) + i = s.expect (['password:', 'yes/no']) + if i == 1: + s.sendline ('yes') + s.expect ('password') + s.sendline (PASSWORD) + s.expect ('Choose compile farm server') + s.sendline (platform_menu) + s.expect_exact ('$') + s.sendline ('cd pexpect') + s.expect_exact ('$') + s.sendline ('. ./cvs.conf') + s.expect_exact ('$') + s.sendline ('cvs up -d') + s.expect ('password:') + s.sendline (PASSWORD) + s.expect_exact ('$') + s.sendline (platform_python_path) + i = s.expect_exact (['OK','$'], timeout=900) # Tests should not run more than 15 minutes. + if i != 0: + RESULT = s.before + else: + RESULT = 'OK!' + s.sendline ('exit') + s.sendline ('x') + s.close() + except Exception, e: + return 'Exception in platform test: ' + str(e) + return RESULT + +PASSWORD = getpass.getpass('password: ') +results = [] +result = test_platform ('I', 'python tools/testall.py') +results.append (('I', '[PPC - G4] MacOS X 10.1 SERVER Edition', result)) +result = test_platform ('L', 'python tools/testall.py') +results.append (('L', '[Sparc - Ultra60] Linux 2.4 (Debian 3.0)', result)) +result = test_platform ('B', 'python2 tools/testall.py') +results.append (('B', '[x86] Linux 2.4 (Redhat 7.3)', result)) +result = test_platform ('M', '../Python-2.3b1/python tools/testall.py') +results.append (('M', '[Sparc - R220] Sun Solaris (8) #1', result)) +result = test_platform ('G', 'python tools/testall.py') +results.append (('G', '[Alpha] Linux 2.2 (Debian 3.0)', result)) +print results + diff --git a/tools/tweak_files.py b/tools/tweak_files.py new file mode 100755 index 0000000..4ab8b22 --- /dev/null +++ b/tools/tweak_files.py @@ -0,0 +1,45 @@ +''' + +PEXPECT LICENSE + + This license is approved by the OSI and FSF as GPL-compatible. + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2012, Noah Spurrier + PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY + PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE + COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +''' + +import pyed +import sys, os, re + +# extract the version number from the pexpect.py source. +d = pyed.pyed() +d.read ("pexpect.py") +d.first('^__version__') +r = re.search("'([0-9]\.[0-9])'", d.cur_line) +version = r.group(1) + +# Edit the index.html to update current VERSION. +d = pyed.pyed() +d.read ("doc/index.html.template") +for cl in d.match_lines('.*VERSION.*'): + d.cur_line = d.cur_line.replace('VERSION', version) +d.write("doc/index.html") + +# Edit the setup.py to update current VERSION. +d = pyed.pyed() +d.read ("setup.py.template") +for cl in d.match_lines('.*VERSION.*'): + d.cur_line = d.cur_line.replace('VERSION', version) +d.write("setup.py") +os.chmod("setup.py", 0755) diff --git a/tools/websync.py b/tools/websync.py new file mode 100755 index 0000000..a4ee141 --- /dev/null +++ b/tools/websync.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python + +''' +I used to use this to keep the sourceforge pages up to date with the +latest documentation and I like to keep a copy of the distribution +on the web site so that it will be compatible with +The Vaults of Parnasus which requires a direct URL link to a +tar ball distribution. I don't advertise the package this way. + +PEXPECT LICENSE + + This license is approved by the OSI and FSF as GPL-compatible. + http://opensource.org/licenses/isc-license.txt + + Copyright (c) 2012, Noah Spurrier + PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY + PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE + COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +''' + +import pexpect, pyed +import getpass +import sys, os + +X = getpass.getpass('Password: ') +pp_pattern=["(?i)password:", "(?i)enter passphrase for key '.*?':"] + +p = pexpect.spawn ('scp -r doc/. noah@shell.sourceforge.net:/home/groups/p/pe/pexpect/htdocs/.') +p.logfile_read = sys.stdout +p.expect (pp_pattern) +p.sendline (X) +p.expect (pexpect.EOF) +print p.before + +p = pexpect.spawn ('scp doc/clean.css doc/email.png noah@shell.sourceforge.net:/home/groups/p/pe/pexpect/htdocs/clean.css') +p.logfile_read = sys.stdout +p.expect (pp_pattern) +p.sendline (X) +p.expect (pexpect.EOF) +print p.before + +#p = pexpect.spawn ('ssh noah@use-pr-shell1.sourceforge.net "cd htdocs;tar zxvf pexpect-doc.tgz"') +#p.logfile_read = sys.stdout +#p.expect ('password:') +#p.sendline (X) +#p.expect (pexpect.EOF) +#print p.before + +p = pexpect.spawn ('scp dist/pexpect-*.tar.gz noah@shell.sourceforge.net:/home/groups/p/pe/pexpect/htdocs/.') +p.logfile_read = sys.stdout +p.expect (pp_pattern) +p.sendline (X) +p.expect (pexpect.EOF) +print p.before + -- cgit v1.2.1