示例#1
0
def main():
    ktk.clearScreen()
    if not manage_file_exist():
        cit.err('No manage.py detected. Please run this under projects folder')
        cit.bye()
    while True:
        to_run = show_menu()
        to_run()
示例#2
0
def requirements_install():
    """Install necessary modules by pip & requirements.pip"""
    if not os.path.exists('./requirements.pip'):
        cit.err('No requirements.pip detected.')
        cit.bye()
    if 'win' in sys.platform:
        ktk.runCmd('pip3 install -r requirements.pip')
    else:
        ktk.runCmd('sudo pip3 install -r requirements.pip')
示例#3
0
def requirements_install():
    """Install necessary modules by pip with requirements.pip

    Globals:
        PIP_REQUIREMENTS: the filename of requirements.pip
    """
    if not os.path.exists('./{}'.format(PIP_REQUIREMENTS)):
        cit.err('No {} detected.'.format(PIP_REQUIREMENTS))
        cit.bye()
    if 'win' in sys.platform:
        ktk.runCmd('pip3 install -r {}'.format(PIP_REQUIREMENTS))
    else:
        ktk.runCmd('sudo pip3 install -r {}'.format(PIP_REQUIREMENTS))
示例#4
0
def retrieve_data():
    """Retrieve dumped data file from remote server

    Globals:
        DATADUMP_FILE: the filename of target json file
        DATADUMP_SERVER: the server's address
        DATADUMP_DIR: the datadump file's folder path on server
        DATADUMP_USER: the username on server
    Inputs:
        addr: Server IP / Address
        username: username on server
        dir: dir on server, DATADUMP file should in it.
    """
    server_info = {
        'addr': cit.get_input('Server: (Default: {})'.format(DATADUMP_SERVER)) or DATADUMP_SERVER,
        'username': cit.get_input('Username: (Default: {})'.format(DATADUMP_USER)) or DATADUMP_USER,
        'dir': cit.get_input('File Dir: (Default: {})'.format(DATADUMP_DIR)) or DATADUMP_DIR,
    }
    if server_info['dir'][-1] == '/':
        server_info['dir'] = server_info['dir'][:-1]
    ktk.runCmd('scp {username}@{addr}:{dir}/{dd} .'.format(**server_info, dd=DATADUMP_FILE))
示例#5
0
def run_by_py3(cmd):
    ktk.runCmd("{py3} {cmd}".format(py3=ktk.getPyCmd(), cmd=cmd))
示例#6
0
def assume_unchanged():
    """Show and add a file to 'No-tracking' in Git"""
    cit.info('Current assume unchanged files:')
    ktk.runCmd('git ls-files -v | grep -e "^[hsmrck]"')
    filename = cit.get_input("Enter a TRACKED file's filename: (Ctrl + C to stop)")
    ktk.runCmd('git update-index --assume-unchanged {}'.format(filename))
示例#7
0
def update_djangotool():
    """Check and update djangoTool.py from github"""
    url = "https://raw.githubusercontent.com/kyan001/PyMyApps/master/DjangoTool/djangoTool.py"
    if ktk.updateFile(__file__, url):
        run_by_py3(__file__)
        cit.bye(0)
示例#8
0
def run_by_py3(cmd):
    py3_cmd = 'py' if 'win32' in sys.platform else 'python3'
    ktk.runCmd("{py3} {cmd}".format(py3=py3_cmd, cmd=cmd))