Exemple #1
0
def main():
    
    # init info
    print('update: INFO: start update plugin ')
    
    # load config file
    update.load_config()
    # process config content
    root_path = update.etc['root_path']
    conf = update.etc['conf']
    
    tmp_path = os.path.join(root_path, conf['local']['tmp_path'])
    etc['tmp_path'] = tmp_path
    
    conf_file = os.path.join(root_path, update.CONFIG_FILE)
    print('update: [ OK ] load config file \"' + base.rel_path(conf_file) + '\"')
    
    # update youtube_dl first
    exit_code = update_sub()
    if exit_code != 0:
        print('update: ERROR: update sub failed. ')
        exit(1)	# exit with an error
        return True
    else:	# update youtube_dl OK
        print('update: [ OK ] update sub done. ')
    
    # do not check, just download and pack
    zip_url = conf['remote']['plugin_zip']
    print('\nupdate: INFO: download lieying_plugin zip file from \"' + zip_url + '\" ')
    
    # make zip file path
    zip_file = os.path.join(tmp_path, os.path.basename(zip_url))
    if not (zip_file.endswith('.zip')):
        zip_file += '.zip'
    # do download
    ed_byte = update.dl_file(zip_url, zip_file)
    # download info
    print('update: [ OK ] saved ' + base.byte2size(ed_byte, True) + ' to \"' + base.rel_path(zip_file) + '\"')
    
    etc['zip_file'] = zip_file
    
    # extract pack
    print('')
    extract_pack()
    # make plugin zip bag
    zip_bag = conf['local']['plugin_zip_file']
    zip_bag = os.path.join(root_path, zip_bag)
    # TODO should auto-gen file name here TODO
    pack_zip(zip_bag)
    
    # done
    print('\nupdate: done')
def main():

    # init info
    print('update: INFO: start update youtube-dl ')

    # get and process command line args
    get_args()

    # load config file
    update.load_config()
    # process config content
    root_path = update.etc['root_path']
    conf = update.etc['conf']

    tmp_path = os.path.join(root_path, conf['local']['tmp_path'])
    etc['tmp_path'] = tmp_path

    conf_file = os.path.join(root_path, update.CONFIG_FILE)
    print('update: [ OK ] load config file \"' + base.rel_path(conf_file) +
          '\"')

    # check flags
    if etc['flag_dl_github']:
        # check latest commit
        if not check_latest_commit():
            # no need to update
            print('update: done')
            return

        # start real update
        zip_url = etc['g_zip_url']
        print('update: INFO: download youtube-dl zip file from \"' + zip_url +
              '\" ')

        # make zip file path
        zip_file = os.path.join(tmp_path, os.path.basename(zip_url))
        if not (zip_file.endswith('.zip')):
            zip_file += '.zip'
        # do download
        ed_byte = update.dl_file(zip_url, zip_file)
        # download info
        print('update: [ OK ] saved ' + base.byte2size(ed_byte, True) +
              ' to \"' + base.rel_path(zip_file) + '\"')

        etc['zip_file'] = zip_file

        # extract zip file
        extract_pack()
        # move files
        mv_file()
    # check and download from github, done

    # check flag
    if etc['flag_pack_zip']:
        # re-pack
        re_pack()

    # check flag
    if etc['flag_dl_github']:
        latest_commit_file = conf['local']['youtube_dl_latest_commit']
        latest_commit_file = os.path.join(root_path, latest_commit_file)
        g_latest_commit = etc['g_latest_commit']
        # update latest commit
        print('update: INFO: save latest commit [' + g_latest_commit +
              '] to \"' + base.rel_path(latest_commit_file) + '\" ')
        with open(latest_commit_file, 'w') as f:
            f.write(g_latest_commit)
    # done
    print('update: [ OK ] done. All works finished. ')
def main():
    
    # init info
    print('update: INFO: start update youtube-dl ')
    
    # get and process command line args
    get_args()
    
    # load config file
    update.load_config()
    # process config content
    root_path = update.etc['root_path']
    conf = update.etc['conf']
    
    tmp_path = os.path.join(root_path, conf['local']['tmp_path'])
    etc['tmp_path'] = tmp_path
    
    conf_file = os.path.join(root_path, update.CONFIG_FILE)
    print('update: [ OK ] load config file \"' + base.rel_path(conf_file) + '\"')
    
    # check flags
    if etc['flag_dl_github']:
        # check latest commit
        if not check_latest_commit():
            # no need to update
            print('update: done')
            return
        
        # start real update
        zip_url = etc['g_zip_url']
        print('update: INFO: download youtube-dl zip file from \"' + zip_url + '\" ')
        
        # make zip file path
        zip_file = os.path.join(tmp_path, os.path.basename(zip_url))
        if not (zip_file.endswith('.zip')):
            zip_file += '.zip'
        # do download
        ed_byte = update.dl_file(zip_url, zip_file)
        # download info
        print('update: [ OK ] saved ' + base.byte2size(ed_byte, True) + ' to \"' + base.rel_path(zip_file) + '\"')
        
        etc['zip_file'] = zip_file
        
        # extract zip file
        extract_pack()
        # move files
        mv_file()
    # check and download from github, done
    
    # check flag
    if etc['flag_pack_zip']:
        # re-pack
        re_pack()
    
    # check flag
    if etc['flag_dl_github']:
        latest_commit_file = conf['local']['youtube_dl_latest_commit']
        latest_commit_file = os.path.join(root_path, latest_commit_file)
        g_latest_commit = etc['g_latest_commit']
        # update latest commit
        print('update: INFO: save latest commit [' + g_latest_commit + '] to \"' + base.rel_path(latest_commit_file) + '\" ')
        with open(latest_commit_file, 'w') as f:
            f.write(g_latest_commit)
    # done
    print('update: [ OK ] done. All works finished. ')