Exemplo n.º 1
0
def rmdir(path):
    if sys.platform == 'cli':
        if not dir_exists(path):
            return
        else:
            Directory.Delete(path, True)
    else:
        shutil.rmtree(path)
Exemplo n.º 2
0
def unzip(path, parent):
    if sys.platform == 'cli':
        out_dir = str(tuple(ZipFile.OpenRead(path).Entries)[0])
        if dir_exists(out_dir):
            Directory.Delete(out_dir, True)
        ZipFile.ExtractToDirectory(path, parent)
        if 'latest' in path:
            return out_dir
    else:
        with zipfile.ZipFile(item) as zf:
            zf.extractall()
            if 'latest' in path:
                return zf.filelist[0].filename
    return None
Exemplo n.º 3
0
def cleanUp():
    '''
    Just removes the DLLs directory we created.
    '''
    #the following while loop is necessary as
    #the Delete call fails (ipy.exe subprocess has
    #not really released some files yet).
    while 1:
        try:
            Directory.Delete(DLLS_DIR, True)
            break
        except:
            from time import sleep
            sleep(1)
            continue
__author__ = "BillyNoodles"
__version__ = "2.0.0"

from BrawlCrate.API import BrawlAPI
from System.IO import Path
from System.IO import Directory

preset_name = "MKW Boost"
preset_path = Path.Combine(BrawlAPI.PluginPath, "MKWii Animations",
                           preset_name)

if BrawlAPI.ShowYesNoWarning("Are you sure you want to delete this preset?",
                             "Delete Preset"):
    Directory.Delete(preset_path, True)
    BrawlAPI.RootNode._mainForm.reloadPluginsToolStripMenuItem_Click(
        None, None)
Exemplo n.º 5
0
def deleteDirectory(directory):
    if Directory.Exists(directory):
        Directory.Delete(directory, True)
Exemplo n.º 6
0
# create the name for the required TMP folder and the output OME-TIFF
tmpfolder = Path.Combine(Path.GetDirectoryName(czifile),
                         Path.GetFileNameWithoutExtension(czifile))
omefile = tmpfolder + '_PY.ome.tiff'
print 'TMP Folder : ', tmpfolder
print 'OME-TIFF to be created : ', omefile

# define parameters and run bioformats2raw
bf2raw_params = '"' + czifile + '" ' + '"' + tmpfolder + '"' + ' --resolutions ' + str(
    resolutions) + ' --compression=raw'
print 'Command String : ', bf2raw_params
done1 = run_tool(bf2raw, bf2raw_params)
print 'Done with conversion to RAW.', done1

# # define parameters and run raw2ometiff
raw2ome_params = '"' + tmpfolder + '" ' + '"' + omefile + '"' + ' --compression=' + compression
print 'Command String : ', raw2ome_params
done2 = run_tool(raw2ome, raw2ome_params)
print 'Done with conversion to pyramidal OME-TIFF', done2

# delete bfmemo file and TMP folder
if cleanup:
    print 'Cleaning up ...'
    delname = Path.Combine(czidir, '.' + cziname + '.bfmemo')
    print 'Deleting : ', delname
    File.Delete(delname)
    print 'Deleting Folder : ', tmpfolder
    Directory.Delete(tmpfolder, True)

print 'Done.'
Exemplo n.º 7
0
    # get the version attribute
    version_number = item.GetAttribute('Version')
    print('Old version : ', version_number)
    try:
        # set the new version number
        item.SetAttribute('Version', newversion)
        print('Set the Modelversion to: ', newversion)
    except:
        # stop the script execution completely
        sys.exit('Could not update the Version number.')

# get the raw XML and write it to disk
rawXML = xmldoc.OuterXml
File.WriteAllText(modelxml, rawXML)

# zip the folder with the updated XML file
print('Started zipping ...')
zipfile = zipfolder(tempdir, tempdir)
change_dir_sep(zipfile)
print('Finished zipping: ', tempdir)

# rename the new zipfile to *.czmodel
print('Rename *.zip back to *.czmodel')
File.Move(zipfile, Path.ChangeExtension(zipfile, '.czmodel'))

# remover the temp folder from unzipping afterwards
if remove_tmpfolder:
    print('Deleting tempory folder : ', tempdir)
    Directory.Delete(tempdir, True)
print('Done.')