예제 #1
0
def restore_option(filexml, pathopt):
    global nowts

    cmd = f"rm -f {pathopt}/{filexml}"
    pr(cmd, "restore_option rm:")
    shsudo(cmd, sudopass)

    xmlbackup = f"options_{nowts}"
    xmlbackup = pathopt.replace("/options'", f"/{xmlbackup}/{filexml}'")
    cmd = f"cp {xmlbackup} {pathopt}"
    pr(cmd, "restore_option cp:")
    shsudo(cmd, sudopass)
예제 #2
0
def restore(folderbk=""):
    global nowts
    if not folderbk:
        folderbk = nowts
    else:
        nowts = folderbk

    restore_option(dicconf["restore1"], dicconf["pathappsup4"])
    restore_option(dicconf["restore2"], dicconf["pathappsup4"])
    restore_option(dicconf["restore3"], dicconf["pathappsup4"])

    pr("\nopen -a Phpstorm")
    print("\n end phpstorm.restore")
예제 #3
0
def index(supass):
    if not supass:
        pr("No sudo pass")
        die()

    global sudopass
    sudopass = supass
    pr(sudopass, "sudopass")

    rmdir(dicconf["pathcache1"])

    rmdir(dicconf["pathappsup1"])
    rmdirall(dicconf["pathappsup2"])
    rmfile(dicconf["pathappsup3"])
    mvdir(dicconf["pathappsup4"])  #options
    rmfile(dicconf["pathappsup5"])
    rmfile(dicconf["pathappsup6"])
    rmfile(dicconf["pathappsup7"])
    rmfile(dicconf["pathappsup8"])

    rmfile(dicconf["pathprefs1"])
    rmfile(dicconf["pathprefs2"])
    rmfile(dicconf["pathprefs3"])

    #rmfile(dicconf["pathapps1"])

    #pathmanual = dicconf["pathxmlmanual"]
    pr(
        f"open -a Xcode /Users/ioedu/Library/Preferences/com.apple.java.util.prefs.plist",
        "\n\tHay que editar esto manualmente y GUARDAR\n\t")
    # pr("\n\t cd /Users/ioedu/Library/Preferences/; dir.sh .")
    pr("\nafter welcome modal run: \n\t py.sh phpstorm.restore  <mmdd>")
    print("\n end phpstorm")
예제 #4
0
def reducedpi(pathfolder, resolution=100):
    resolution = int(resolution)
    timeini = get_now()
    pr(f"image.reducedpi: {timeini}")
    print(f"process: pathfolder={pathfolder}, resolution={resolution}")

    if not is_dir(pathfolder):
        return die(f"Error pathfolder {pathfolder} is not a directory")

    files = scandir(pathfolder)
    newfolder = f"{pathfolder}/res_{resolution}x{resolution}"
    if files:
        mkdir(newfolder)

    for filename in files:
        pr(f"handling: {filename}")

        pathfile = f"{pathfolder}/{filename}"
        if not is_extensionok(filename) or is_dir(pathfile):
            continue

        extension = os.path.splitext(filename)[1].replace(".", "")
        pathfilenew = os.path.splitext(pathfile)[0]

        pathfilenew = get_basename(pathfilenew)
        pathfilenew = f"{newfolder}/{pathfilenew}-{resolution}x{resolution}.{extension}"

        pr(f"generated file: {pathfilenew}")
        objimg = Image.open(pathfile)
        objimg.save(pathfilenew, dpi=(resolution, resolution))

    timeend = get_now()
    pr(f"...image reduce of {pathfolder} has finished. ini:{timeini} - end:{timeend}"
       )
예제 #5
0
파일: udemy.py 프로젝트: eacevedof/prj_bash
def index(pathfile):
    pr("\n - BEGIN - \n\n")
    strcont = file_get_contents(pathfile)
    arlines = strcont.split("\n")
    # quito lineas en blanco
    arclean = list(filter(lambda strline: strline.strip()!="", arlines))
    #pr(arclean,"arclean")
    arpostitl = get_titles_pos(arclean)
    #pr(arpostitl,"arpostitle")

    artitles = []
    # trato el titulo de sección
    imin = arpostitl[0]
    artitles.append(" ".join(arclean[0:imin]))
    
    for ipostitle in arpostitl:
        strtitle = get_title_min(ipostitle, arpostitl, arclean)
        artitles.append(strtitle)

    # pr(artitles,"artitles")
    artagged = []
    for i,title in enumerate(artitles):
        if(i>0):
            artagged.append(f"### [{title}]()")
            artagged.append("- ")
        else:
            artagged.append(f"### {title}")

    # pr(artagged,"artagged")
    newfile = f"{pathfile}.bk"
    strcontent = "\n".join(artagged)
    pr(strcontent)
    file_put_contents(newfile,strcontent)
    pr("\n - END - \n")
예제 #6
0
def rmfile(pathfile):
    cmd = f"rm -f {pathfile}"
    pr(cmd, "rmfile:")
    shsudo(cmd, sudopass)
예제 #7
0
def rmdirall(pathfolder):
    cmd = f"rm -f {pathfolder}/*"
    pr(cmd, "rmdirall:")
    shsudo(cmd, sudopass)
예제 #8
0
def rmdir(pathdir):
    cmd = f"rm -fr {pathdir}"
    pr(cmd, "rmdir:")
    shsudo(cmd, sudopass)