def create_lisa_data_dir_tree(oseg=None): odp = op.expanduser('~/lisa_data/.lisa/') if not op.exists(odp): os.makedirs(odp) # import wget lisa_icon_path= path(".lisa/LISA256.png") if not op.exists(lisa_icon_path): try: download_file( "https://raw.githubusercontent.com/mjirik/lisa/master/lisa/icons/LISA256.png", filename=lisa_icon_path) # wget.download( # "https://raw.githubusercontent.com/mjirik/lisa/master/lisa/icons/LISA256.png", # out=lisa_icon_path) except: import traceback logger.warning('logo download failed') logger.warning(traceback.format_exc()) if oseg is not None: # used for server sync oseg._output_datapath_from_server = op.join(oseg.output_datapath, 'sync', oseg.sftp_username, "from_server/") # used for server sync oseg._output_datapath_to_server = op.join(oseg.output_datapath, 'sync', oseg.sftp_username, "to_server/") odp = oseg.output_datapath if not op.exists(odp): os.makedirs(odp) odp = oseg._output_datapath_from_server if not op.exists(odp): os.makedirs(odp) odp = oseg._output_datapath_to_server if not op.exists(odp): os.makedirs(odp)
def __make_icon_osx(): lisa_shortcut = op.expanduser("~/Desktop/lisa") if not os.path.exists(lisa_shortcut): with open(lisa_shortcut, 'w') as outfile: outfile.write( "\ #!/bin/bash\n\ export PATH=$HOME/miniconda2/bin:$HOME/anaconda2/bin:$HOME/miniconda/bin:$HOME/anaconda/bin:$PATH\n\ lisa" ) os.chmod(lisa_shortcut, stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXOTH | stat.S_IWUSR | stat.S_IWGRP ) lisa_icon_path= op.expanduser("~/lisa_data/.lisa/LISA256.icns") if not os.path.exists(lisa_icon_path): try: download_file( # wget.download( "https://raw.githubusercontent.com/mjirik/lisa/master/applications/LISA256.icns", filename=lisa_icon_path # out=lisa_icon_path ) except: logger.warning('logo download failed') pass
def __make_icon_linux(): # import wget in_path = op.expanduser("~/lisa_data/.lisa/lisa.desktop.in") rm_smart(in_path) lisa_icon_path= op.expanduser("~/lisa_data/.lisa/LISA256.png") # if not op.exists(in_path): # try: # wget.download( # "https://raw.githubusercontent.com/mjirik/lisa/master/applications/lisa.desktop.in", # out=in_path) # except: # import traceback # logger.warning('logo download failed') # logger.warning(traceback.format_exc()) if not op.exists(lisa_icon_path): try: download_file( # wget.download( "https://raw.githubusercontent.com/mjirik/lisa/master/lisa/icons/LISA256.png", filename=lisa_icon_path) # out=lisa_icon_path) except: import traceback logger.warning('logo download failed') logger.warning(traceback.format_exc()) logger.debug("icon input path:") logger.debug(in_path) home_path = os.path.expanduser('~') if os.path.exists(os.path.join(home_path, 'Desktop')): desktop_path = os.path.join(home_path, 'Desktop') elif os.path.exists(os.path.join(home_path, 'Plocha')): desktop_path = os.path.join(home_path, 'Plocha') else: print("Cannot find desktop directory") logger.error("Cannot find desktop directory") desktop_path = None # copy desktop files to desktop if desktop_path is not None: out_path = os.path.join(desktop_path, "lisa.desktop") __make_linux_icon_file(out_path) # copy desktop files to $HOME/.local/share/applications/ # to be accesable in application menu (Linux) local_app_path = os.path.join(home_path, '.local/share/applications') if os.path.exists(local_app_path) and os.path.isdir(local_app_path): out_path = os.path.join(local_app_path, "lisa.desktop") __make_linux_icon_file(out_path) else: print("Couldnt find $HOME/.local/share/applications/.")
def make_update(dry_run=False): """ Update with no projects/lisa directory :param dry_run: :return: """ import os.path as op conda_ok = True print('Updating conda modules') logger.debug("Updating conda modules") try: cmd = [ "conda", "install", "--yes", # "-c", 'luispedro ', '-c', 'SimpleITK', "-c", "menpo", '-c', 'mjirik', "-c", "menpo", "-c", "auto", "lisa" ] if dry_run: cmd.append('--dry-run') subprocess.call(cmd) except: logger.warning('Problem with conda update') logger.warning(traceback.format_exc()) traceback.print_exc() conda_ok = False # try: # install_and_import('wget', '--user') print('Updating pip modules') logger.debug("Updating pip modules") try: req_txt_path = op.expanduser("~/lisa_data/.lisa/reqirements_pip.txt") if op.exists(req_txt_path): os.remove(req_txt_path) # wget.download( download_file( "https://raw.githubusercontent.com/mjirik/lisa/master/requirements_pip.txt", filename=req_txt_path) cmd = ["pip", "install", '-U', '--no-deps'] if not conda_ok: cmd.append('--user') cmd = cmd + ["-r", req_txt_path] if dry_run: cmd.insert(1, '-V') subprocess.call(cmd) except: logger.warning('Problem with pip update') logger.warning(traceback.format_exc()) traceback.print_exc() try: import lisa_data lisa_data.make_icon() except: logger.warning('Problem with icon') logger.warning(traceback.format_exc()) traceback.print_exc()