1
0
mirror of https://github.com/mnaberez/py65.git synced 2024-06-07 12:29:27 +00:00

Add the ability to load from URLs

This commit is contained in:
Mike Naberezny 2012-01-02 17:13:40 -08:00
parent 3a0807ccec
commit b5c2382364
2 changed files with 21 additions and 8 deletions

View File

@ -5,6 +5,8 @@
- The monitor now accepts command line arguments. See
``py65mon --help`` for usage. Contributed by Ed Spittles.
- The monitor's load command can now fetch URLs.
0.10 (2011-08-27)
- Fixed long-standing bugs in relative branch calculations in the

View File

@ -18,6 +18,7 @@ import os
import re
import shlex
import sys
import urllib2
from asyncore import compact_traceback
from py65.devices.mpu6502 import MPU as NMOS6502
from py65.devices.mpu65c02 import MPU as CMOS65C02
@ -476,14 +477,24 @@ class Monitor(cmd.Cmd):
else:
start = self._mpu.pc
try:
f = open(filename, 'rb')
bytes = f.read()
f.close()
except (OSError, IOError), why:
msg = "Cannot load file: [%d] %s" % (why[0], why[1])
self._output(msg)
return
if "://" in filename:
try:
f = urllib2.urlopen(filename)
bytes = f.read()
f.close()
except (urllib2.URLError, urllib2.HTTPError), why:
msg = "Cannot fetch remote file: %s" % str(why)
self._output(msg)
return
else:
try:
f = open(filename, 'rb')
bytes = f.read()
f.close()
except (OSError, IOError), why:
msg = "Cannot load file: [%d] %s" % (why[0], why[1])
self._output(msg)
return
# if the start address was -1, we load to top of memory
if start == -1: