資源簡介
該資源只在github有更新,但github國內(nèi)用戶下載龜速,解決快速下載使用的痛點。seafile-server_7.0.5是目前最新版的服務(wù)端安裝包。
代碼片段和文件信息
#coding:?UTF-8
‘‘‘This?script?would?check?if?there?is?admin?and?prompt?the?user?to?create?a?new?one?if?non?exist‘‘‘
import?json
import?sys
import?os
import?time
import?re
import?shutil
import?glob
import?subprocess
import?hashlib
import?getpass
import?uuid
import?warnings
from?ConfigParser?import?ConfigParser
try:
????import?readline?#?pylint:?disable=W0611
except?ImportError:
????pass
SERVER_MANUAL_HTTP?=?‘https://github.com/haiwen/seafile/wiki‘
class?Utils(object):
????‘‘‘Groups?all?helper?functions?here‘‘‘
????@staticmethod
????def?welcome():
????????‘‘‘Show?welcome?message‘‘‘
????????welcome_msg?=?‘‘‘\
-----------------------------------------------------------------
This?script?will?guide?you?to?setup?your?seafile?server?using?MySQL.
Make?sure?you?have?read?seafile?server?manual?at
????????%s
Press?ENTER?to?continue
-----------------------------------------------------------------‘‘‘?%?SERVER_MANUAL_HTTP
????????print?welcome_msg
????????raw_input()
????@staticmethod
????def?highlight(content):
????????‘‘‘Add?ANSI?color?to?content?to?get?it?highlighted?on?terminal‘‘‘
????????return?‘\x1b[33m%s\x1b[m‘?%?content
????@staticmethod
????def?info(msg):
????????print?msg
????@staticmethod
????def?error(msg):
????????‘‘‘Print?error?and?exit‘‘‘
????????print
????????print?‘Error:?‘?+?msg
????????sys.exit(1)
????@staticmethod
????def?run_argv(argv?cwd=None?env=None?suppress_stdout=False?suppress_stderr=False):
????????‘‘‘Run?a?program?and?wait?it?to?finish?and?return?its?exit?code.?The
????????standard?output?of?this?program?is?supressed.
????????‘‘‘
????????with?open(os.devnull?‘w‘)?as?devnull:
????????????if?suppress_stdout:
????????????????stdout?=?devnull
????????????else:
????????????????stdout?=?sys.stdout
????????????if?suppress_stderr:
????????????????stderr?=?devnull
????????????else:
????????????????stderr?=?sys.stderr
????????????proc?=?subprocess.Popen(argv
????????????????????????????????????cwd=cwd
????????????????????????????????????stdout=stdout
????????????????????????????????????stderr=stderr
????????????????????????????????????env=env)
????????????return?proc.wait()
????@staticmethod
????def?run(cmdline?cwd=None?env=None?suppress_stdout=False?suppress_stderr=False):
????????‘‘‘Like?run_argv?but?specify?a?command?line?string?instead?of?argv‘‘‘
????????with?open(os.devnull?‘w‘)?as?devnull:
????????????if?suppress_stdout:
????????????????stdout?=?devnull
????????????else:
????????????????stdout?=?sys.stdout
????????????if?suppress_stderr:
????????????????stderr?=?devnull
????????????else:
????????????????stderr?=?sys.stderr
????????????proc?=?subprocess.Popen(cmdline
????????????????????????????????????cwd=cwd
????????????????????????????????????stdout=stdout
????????????????????????????????????stderr=stderr
????????????????????????????????????env=env
????????????????????????????????????shell=True)
????????????return?proc.wait()
????@staticmethod
????def?prepend_env_value(name?value?env=None?
評論
共有 條評論