发布时间:2019-06-25 09:57:28编辑:auto阅读(2054)
最近公司在使用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 space\n')
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
上一篇: Python的系统管理_02python
下一篇: Python编程->cannot ope
48736
47770
38543
35738
30175
26914
25947
20787
20557
18943
335°
410°
443°
464°
453°
442°
495°
565°
680°
700°