Ticket #2868: runscript.diff
File runscript.diff, 1.5 KB (added by , 18 years ago) |
---|
-
django/core/management.py
1189 1189 code.interact() 1190 1190 run_shell.args = '[--plain]' 1191 1191 1192 def runscript(script): 1193 "Runs a python script in the current environment." 1194 import os.path 1195 script = os.path.abspath(script) 1196 new_globals = globals().copy() 1197 new_globals.update({"__name__": "__main__", 1198 "__file__": script}) 1199 try: 1200 execfile(script, new_globals, {}) 1201 except IOError, e: 1202 sys.stderr.write(style.ERROR("%s\n" % e)) 1203 sys.exit(1) 1204 runscript.args = '[path/to/python/script]' 1205 1192 1206 def dbshell(): 1193 1207 "Runs the command-line client for the current DATABASE_ENGINE." 1194 1208 from django.db import runshell … … 1244 1258 'runfcgi': runfcgi, 1245 1259 'runserver': runserver, 1246 1260 'shell': run_shell, 1261 'runscript': runscript, 1247 1262 'sql': get_sql_create, 1248 1263 'sqlall': get_sql_all, 1249 1264 'sqlclear': get_sql_delete, … … 1368 1383 except IndexError: 1369 1384 parser.print_usage_and_exit() 1370 1385 action_mapping[action](name, os.getcwd()) 1386 elif action == 'runscript': 1387 if len(args) != 2: 1388 sys.stderr.write(style.ERROR("Error: You must specify a script to run.\n")) 1389 sys.exit(1) 1390 script = args[1] 1391 action_mapping[action](script) 1371 1392 elif action == 'runserver': 1372 1393 if len(args) < 2: 1373 1394 addr = ''