[Python-checkins] python/dist/src/Demo/sockets broadcast.py, 1.4, 1.5 ftp.py, 1.5, 1.6 gopher.py, 1.4, 1.5 mcast.py, 1.9, 1.10 radio.py, 1.3, 1.4 telnet.py, 1.5, 1.6 udpecho.py, 1.5, 1.6 unicast.py, 1.1, 1.2 unixclient.py, 1.1, 1.2

doerwalter at users.sourceforge.net doerwalter at users.sourceforge.net
Thu Feb 12 12:35:36 EST 2004


Update of /cvsroot/python/python/dist/src/Demo/sockets
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21620/Demo/sockets

Modified Files:
	broadcast.py ftp.py gopher.py mcast.py radio.py telnet.py 
	udpecho.py unicast.py unixclient.py 
Log Message:
Replace backticks with repr() or "%r"

>From SF patch #852334.


Index: broadcast.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/sockets/broadcast.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** broadcast.py	4 Mar 1995 22:57:55 -0000	1.4
--- broadcast.py	12 Feb 2004 17:35:03 -0000	1.5
***************
*** 11,15 ****
  
  while 1:
! 	data = `time.time()` + '\n'
  	s.sendto(data, ('<broadcast>', MYPORT))
  	time.sleep(2)
--- 11,15 ----
  
  while 1:
! 	data = repr(time.time()) + '\n'
  	s.sendto(data, ('<broadcast>', MYPORT))
  	time.sleep(2)

Index: ftp.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/sockets/ftp.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ftp.py	25 Aug 2000 15:38:41 -0000	1.5
--- ftp.py	12 Feb 2004 17:35:03 -0000	1.6
***************
*** 92,96 ****
  	hostaddr = gethostbyname(hostname)
  	hbytes = string.splitfields(hostaddr, '.')
! 	pbytes = [`port/256`, `port%256`]
  	bytes = hbytes + pbytes
  	cmd = 'PORT ' + string.joinfields(bytes, ',')
--- 92,96 ----
  	hostaddr = gethostbyname(hostname)
  	hbytes = string.splitfields(hostaddr, '.')
! 	pbytes = [repr(port/256), repr(port%256)]
  	bytes = hbytes + pbytes
  	cmd = 'PORT ' + string.joinfields(bytes, ',')

Index: gopher.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/sockets/gopher.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** gopher.py	27 Nov 1996 19:50:41 -0000	1.4
--- gopher.py	12 Feb 2004 17:35:03 -0000	1.5
***************
*** 76,83 ****
  		parts = string.splitfields(line[1:], TAB)
  		if len(parts) < 4:
! 			print '(Bad line from server:', `line`, ')'
  			continue
  		if len(parts) > 4:
! 			print '(Extra info from server:', parts[4:], ')'
  		parts.insert(0, typechar)
  		list.append(parts)
--- 76,83 ----
  		parts = string.splitfields(line[1:], TAB)
  		if len(parts) < 4:
! 			print '(Bad line from server: %r)' % (line,)
  			continue
  		if len(parts) > 4:
! 			print '(Extra info from server: %r)' % (parts[4:],)
  		parts.insert(0, typechar)
  		list.append(parts)
***************
*** 155,159 ****
  	while 1:
  		print '----- MENU -----'
! 		print 'Selector:', `selector`
  		print 'Host:', host, ' Port:', port
  		print
--- 155,159 ----
  	while 1:
  		print '----- MENU -----'
! 		print 'Selector:', repr(selector)
  		print 'Host:', host, ' Port:', port
  		print
***************
*** 161,169 ****
  			item = list[i]
  			typechar, description = item[0], item[1]
! 			print string.rjust(`i+1`, 3) + ':', description,
  			if typename.has_key(typechar):
  				print typename[typechar]
  			else:
! 				print '<TYPE=' + `typechar` + '>'
  		print
  		while 1:
--- 161,169 ----
  			item = list[i]
  			typechar, description = item[0], item[1]
! 			print string.rjust(repr(i+1), 3) + ':', description,
  			if typename.has_key(typechar):
  				print typename[typechar]
  			else:
! 				print '<TYPE=' + repr(typechar) + '>'
  		print
  		while 1:
***************
*** 222,226 ****
  	while 1:
  		print '----- SEARCH -----'
! 		print 'Selector:', `selector`
  		print 'Host:', host, ' Port:', port
  		print
--- 222,226 ----
  	while 1:
  		print '----- SEARCH -----'
! 		print 'Selector:', repr(selector)
  		print 'Host:', host, ' Port:', port
  		print
***************
*** 241,247 ****
  def browse_telnet(selector, host, port):
  	if selector:
! 		print 'Log in as', `selector`
  	if type(port) <> type(''):
! 		port = `port`
  	sts = os.system('set -x; exec telnet ' + host + ' ' + port)
  	if sts:
--- 241,247 ----
  def browse_telnet(selector, host, port):
  	if selector:
! 		print 'Log in as', repr(selector)
  	if type(port) <> type(''):
! 		port = repr(port)
  	sts = os.system('set -x; exec telnet ' + host + ' ' + port)
  	if sts:
***************
*** 308,314 ****
  			p = os.popen(cmd, 'w')
  		except IOError, msg:
! 			print `cmd`, ':', msg
  			return None
! 		print 'Piping through', `cmd`, '...'
  		return p
  	if savefile[0] == '~':
--- 308,314 ----
  			p = os.popen(cmd, 'w')
  		except IOError, msg:
! 			print repr(cmd), ':', msg
  			return None
! 		print 'Piping through', repr(cmd), '...'
  		return p
  	if savefile[0] == '~':
***************
*** 317,323 ****
  		f = open(savefile, 'w')
  	except IOError, msg:
! 		print `savefile`, ':', msg
  		return None
! 	print 'Saving to', `savefile`, '...'
  	return f
  
--- 317,323 ----
  		f = open(savefile, 'w')
  	except IOError, msg:
! 		print repr(savefile), ':', msg
  		return None
! 	print 'Saving to', repr(savefile), '...'
  	return f
  

Index: mcast.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/sockets/mcast.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** mcast.py	7 Aug 1999 14:01:05 -0000	1.9
--- mcast.py	12 Feb 2004 17:35:03 -0000	1.10
***************
*** 39,43 ****
  		s.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, ttl)
  	while 1:
! 		data = `time.time()`
  ##		data = data + (1400 - len(data)) * '\0'
  		s.sendto(data, (mygroup, MYPORT))
--- 39,43 ----
  		s.setsockopt(IPPROTO_IP, IP_MULTICAST_TTL, ttl)
  	while 1:
! 		data = repr(time.time())
  ##		data = data + (1400 - len(data)) * '\0'
  		s.sendto(data, (mygroup, MYPORT))
***************
*** 54,58 ****
  		data, sender = s.recvfrom(1500)
  		while data[-1:] == '\0': data = data[:-1] # Strip trailing \0's
! 		print sender, ':', `data`
  
  
--- 54,58 ----
  		data, sender = s.recvfrom(1500)
  		while data[-1:] == '\0': data = data[:-1] # Strip trailing \0's
! 		print sender, ':', repr(data)
  
  

Index: radio.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/sockets/radio.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** radio.py	8 Oct 1994 19:13:48 -0000	1.3
--- radio.py	12 Feb 2004 17:35:03 -0000	1.4
***************
*** 11,14 ****
  while 1:
  	data, wherefrom = s.recvfrom(1500, 0)
! 	sys.stderr.write(`wherefrom` + '\n')
  	sys.stdout.write(data)
--- 11,14 ----
  while 1:
  	data, wherefrom = s.recvfrom(1500, 0)
! 	sys.stderr.write(repr(wherefrom) + '\n')
  	sys.stdout.write(data)

Index: telnet.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/sockets/telnet.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** telnet.py	25 Aug 2000 15:38:41 -0000	1.5
--- telnet.py	12 Feb 2004 17:35:03 -0000	1.6
***************
*** 54,58 ****
  		s.connect((host, port))
  	except error, msg:
! 		sys.stderr.write('connect failed: ' + `msg` + '\n')
  		sys.exit(1)
  	#
--- 54,58 ----
  		s.connect((host, port))
  	except error, msg:
! 		sys.stderr.write('connect failed: ' + repr(msg) + '\n')
  		sys.exit(1)
  	#

Index: udpecho.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/sockets/udpecho.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** udpecho.py	25 Aug 2000 15:38:41 -0000	1.5
--- udpecho.py	12 Feb 2004 17:35:03 -0000	1.6
***************
*** 38,42 ****
  	while 1:
  		data, addr = s.recvfrom(BUFSIZE)
! 		print 'server received', `data`, 'from', `addr`
  		s.sendto(data, addr)
  
--- 38,42 ----
  	while 1:
  		data, addr = s.recvfrom(BUFSIZE)
! 		print 'server received %r from %r' % (data, addr)
  		s.sendto(data, addr)
  
***************
*** 59,63 ****
  		s.sendto(line, addr)
  		data, fromaddr = s.recvfrom(BUFSIZE)
! 		print 'client received', `data`, 'from', `fromaddr`
  
  main()
--- 59,63 ----
  		s.sendto(line, addr)
  		data, fromaddr = s.recvfrom(BUFSIZE)
! 		print 'client received %r from %r' % (data, fromaddr)
  
  main()

Index: unicast.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/sockets/unicast.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** unicast.py	21 Aug 1996 20:11:55 -0000	1.1
--- unicast.py	12 Feb 2004 17:35:03 -0000	1.2
***************
*** 10,14 ****
  
  while 1:
! 	data = `time.time()` + '\n'
  	s.sendto(data, ('', MYPORT))
  	time.sleep(2)
--- 10,14 ----
  
  while 1:
! 	data = repr(time.time()) + '\n'
  	s.sendto(data, ('', MYPORT))
  	time.sleep(2)

Index: unixclient.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Demo/sockets/unixclient.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** unixclient.py	28 Jan 1998 16:53:57 -0000	1.1
--- unixclient.py	12 Feb 2004 17:35:03 -0000	1.2
***************
*** 8,10 ****
  data = s.recv(1024)
  s.close()
! print 'Received', `data`
--- 8,10 ----
  data = s.recv(1024)
  s.close()
! print 'Received', repr(data)




More information about the Python-checkins mailing list