You are not logged in.
When I try running a python file for this, I get:
'modding/cleanup.sh'
File "runtime/cleanup.py", line 31
print 'WARNING:'
^
SyntaxError: invalid syntax
Here is the contents of the cleanup.py file:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 9 13:51:48 2011
@author: ProfMobius & Searge
@version: v1.0
"""
import sys
import os
import glob
import logging
from optparse import OptionParser
from commands import Commands, reallyrmtree
def main():
parser = OptionParser(version='MCP %s' % Commands.fullversion())
parser.add_option('-f', '--force', action='store_true', dest='force', help='force cleanup', default=False)
parser.add_option('-c', '--config', dest='config', help='additional configuration file')
options, _ = parser.parse_args()
cleanup(options.config, options.force)
def cleanup(conffile, force):
try:
commands = Commands(conffile)
if not force:
print 'WARNING:'
print 'The cleanup script will delete all folders created by MCP, including the'
print 'src folder which may contain changes you made to the code, along with any'
print 'saved worlds from the client or server.'
answer = raw_input('If you really want to clean up, enter "Yes" ')
if answer.lower() not in ['yes']:
print 'You have not entered "Yes", aborting the clean up process'
sys.exit(1)
commands.checkupdates()
try:
commands.logger.info('> Cleaning temp')
reallyrmtree(commands.dirtemp)
commands.logger.info('> Cleaning src')
reallyrmtree(commands.dirsrc)
commands.logger.info('> Cleaning bin')
reallyrmtree(commands.dirbin)
commands.logger.info('> Cleaning reobf')
reallyrmtree(commands.dirreobf)
commands.logger.info('> Cleaning lib')
reallyrmtree(commands.dirlib)
commands.logger.info('> Cleaning jars')
reallyrmtree(os.path.join(commands.dirjars, 'saves'))
reallyrmtree(os.path.join(commands.dirjars, 'stats'))
reallyrmtree(os.path.join(commands.dirjars, 'texturepacks'))
reallyrmtree(os.path.join(commands.dirjars, 'texturepacks-mp-cache'))
reallyrmtree(os.path.join(commands.dirjars, 'mcpworld'))
if os.path.exists(os.path.join(commands.dirjars, 'server.log')):
os.remove(os.path.join(commands.dirjars, 'server.log'))
for txt_file in glob.glob(os.path.join(commands.dirjars, '*.txt')):
os.remove(txt_file)
commands.logger.info('> Cleaning logs')
logging.shutdown()
reallyrmtree(commands.dirlogs)
except OSError as ex:
print >> sys.stderr, 'Cleanup FAILED'
if hasattr(ex, 'filename'):
print >> sys.stderr, 'Failed to remove ' + ex.filename
sys.exit(1)
except Exception: # pylint: disable-msg=W0703
logging.exception('FATAL ERROR')
sys.exit(1)
if __name__ == '__main__':
main()
Thanks for the help
Last edited by treeman1111 (2013-02-23 18:28:34)
Offline
Most likely you try to run it with /usr/bin/python, which is the Python 3 interpreter, and the script is written for Python 2. Use 'python2 script.py' to start it in Python 2.
Last edited by kaszak696 (2013-02-23 18:25:01)
'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard
Offline
Awesome! I will give it a try.
Offline
Thank you very much for the help.
Offline