最近公司在使用redmine来管理项目,为了便利维护,用python写了两个小程序,和大家分享一下
启动和关闭:
#!/usr/bin/env python
'''Use this script to change redmine status(start or stop)
write by liyufeng
data 2013 -5 -8'''
import subprocess
print('1.Stop , Please input "stop". n2.Start , Plase input "start".n3.Quit , Plase press spacen')
redminestatus = raw_input('Please input Status:')
try:
if redminestatus == 'stop':
subprocess.call("ps -ef |grep redmine | awk '{print $2}' |xargs kill -9",shell=True)
print '---------------------------'
print '-redmine-status is STOP!!!-'
print '---------------------------'
if redminestatus == 'start':
subprocess.call('ruby /usr/local/redmine/script/rails server webrick -e production -d',shell=True)
print '-------------------------'
print '-redmine-status is START-'
print '-------------------------'
except:
pass
修改密码:
#!/usr/bin/env python
'''Use this script to Change the admin password
write by liyufeng
data = 2013/5/8'''
import subprocess
data = raw_input('Please input password:')
subprocess.call("""RAILS_ENV=production script/rails runner 'user = User.find(:first, :conditions => {:admin => true}) ; user.password, user.password_confirmation = "%s"; user.save!'""",shell = True) % data