Ticket #4086: twisted4086.4.patch
| File twisted4086.4.patch, 5.1 KB (added by necaris, 14 months ago) |
|---|
-
twisted/topfiles/4086.removal
1 The 'unsigned' flag to twisted.scripts.tap2rpm.MyOptions is now deprecated. -
twisted/scripts/test/test_tap2rpm.py
5 5 Tests for L{twisted.scripts.tap2rpm}. 6 6 """ 7 7 import os 8 8 9 from twisted.trial.unittest import TestCase, SkipTest 9 10 from twisted.python import procutils 11 from twisted.python import versions 12 from twisted.python import deprecate 10 13 from twisted.python.failure import Failure 11 14 from twisted.internet import utils 12 15 from twisted.scripts import tap2rpm … … 378 381 379 382 # Try and make an RPM from that tapfile. 380 383 _makeRPMs(tapfile=tapfile) 384 385 386 def test_unsignedFlagDeprecationWarning(self): 387 """ 388 The 'unsigned' flag in tap2rpm should be deprecated, and its use 389 should raise a warning as such. 390 """ 391 config = tap2rpm.MyOptions() 392 config.parseOptions(['--unsigned']) 393 warnings = self.flushWarnings() 394 self.assertEqual(DeprecationWarning, warnings[0]['category']) 395 self.assertEqual( 396 deprecate.getDeprecationWarningString( 397 config.opt_unsigned, versions.Version("Twisted", 12, 1, 0)), 398 warnings[0]['message']) 399 self.assertEqual(1, len(warnings)) -
twisted/scripts/tap2rpm.py
7 7 import tempfile 8 8 import tarfile 9 9 from StringIO import StringIO 10 import warnings 10 11 11 from twisted.python import usage, log 12 from twisted.python import usage, log, versions, deprecate 12 13 13 14 14 15 ################################# … … 36 37 # check for required files 37 38 if [ ! -x /usr/bin/twistd ] 38 39 then 39 echo "$0: Aborting, no /usr/bin/twistd found"40 exit 040 echo "$0: Aborting, no /usr/bin/twistd found" 41 exit 0 41 42 fi 42 43 if [ ! -r "$file" ] 43 44 then 44 echo "$0: Aborting, no file $file found."45 exit 045 echo "$0: Aborting, no file $file found." 46 exit 0 46 47 fi 47 48 48 49 # set up run directory if necessary 49 50 if [ ! -d "${rundir}" ] 50 51 then 51 mkdir -p "${rundir}"52 mkdir -p "${rundir}" 52 53 fi 53 54 54 55 55 56 case "$1" in 56 start)57 echo -n "Starting %(rpm_file)s: twistd"58 daemon twistd \\59 --pidfile=$pidfile \\60 --rundir=$rundir \\61 --%(twistd_option)s=$file \\62 --logfile=$logfile63 status %(rpm_file)s64 ;;57 start) 58 echo -n "Starting %(rpm_file)s: twistd" 59 daemon twistd \\ 60 --pidfile=$pidfile \\ 61 --rundir=$rundir \\ 62 --%(twistd_option)s=$file \\ 63 --logfile=$logfile 64 status %(rpm_file)s 65 ;; 65 66 66 stop)67 echo -n "Stopping %(rpm_file)s: twistd"68 kill `cat "${pidfile}"`69 status %(rpm_file)s70 ;;67 stop) 68 echo -n "Stopping %(rpm_file)s: twistd" 69 kill `cat "${pidfile}"` 70 status %(rpm_file)s 71 ;; 71 72 72 restart)73 "${0}" stop74 "${0}" start75 ;;73 restart) 74 "${0}" stop 75 "${0}" start 76 ;; 76 77 77 78 *) 78 echo "Usage: ${0} {start|stop|restart|}" >&279 exit 180 ;;79 echo "Usage: ${0} {start|stop|restart|}" >&2 80 exit 1 81 ;; 81 82 esac 82 83 83 84 exit 0 … … 106 107 107 108 %%install 108 109 [ ! -z "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != '/' ] \ 109 && rm -rf "$RPM_BUILD_ROOT"110 && rm -rf "$RPM_BUILD_ROOT" 110 111 mkdir -p "$RPM_BUILD_ROOT"/etc/twisted-taps 111 112 mkdir -p "$RPM_BUILD_ROOT"/etc/init.d 112 113 mkdir -p "$RPM_BUILD_ROOT"/var/lib/twisted-taps … … 115 116 116 117 %%clean 117 118 [ ! -z "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != '/' ] \ 118 && rm -rf "$RPM_BUILD_ROOT"119 && rm -rf "$RPM_BUILD_ROOT" 119 120 120 121 %%post 121 122 /sbin/chkconfig --add %(rpm_file)s … … 138 139 139 140 ############################### 140 141 class MyOptions(usage.Options): 141 optFlags = [[ "unsigned", "u"], ['quiet', 'q']]142 optFlags = [['quiet', 'q']] 142 143 optParameters = [ 143 144 ["tapfile", "t", "twistd.tap"], 144 145 ["maintainer", "m", "tap2rpm"], … … 176 177 self['twistd_option'] = type_dict[self['type']] 177 178 self['release-name'] = '%s-%s' % (self['rpmfile'], self['set-version']) 178 179 180 def opt_unsigned(self): 181 """ 182 Handle the 'unsigned' command-line flag, which is now deprecated in 183 any case. 184 """ 185 msg = deprecate.getDeprecationWarningString( 186 self.opt_unsigned, versions.Version("Twisted", 12, 1, 0)) 187 warnings.warn(msg, category=DeprecationWarning, stacklevel=2) 179 188 189 # Maintain the -u short flag 190 opt_u = opt_unsigned 180 191 192 181 193 type_dict = { 182 194 'tap': 'file', 183 195 'python': 'python',
