Education Of The Woogle Bug

by Mike Levin

Saturday, June 18, 2022

Wow, yesterday was epic for so many reasons. Not only did I rewrite my content management system, but my child rejected me when I picked them up for Father’s Day weekend by calling the police on me… for raising my voice and telling them the truth. Their current feelings towards me are as a direct result of my ex sharing them in on a private conversation which was a gross violation not only of our agreement, but of common decency and now my child’s mind is poisoned against me. They good news is that they are still very young and smart and in time they will come to understand what happened. The police are very sympathetic and gave some good suggestions about trying to get my child into public school. I agree.

So here I am on a morning I did not think I was gong to have and am free to write. Part of what I am going to do is document the events of yesterday and last night while it is fresh on my mind. But more important still, I am going to condition my mind for kindness and gentleness. There is a Tin Woodman who wouldn’t hurt a fly (yet you ought to read the books), a Scarecrow who can think his way through any situation and a Cowardly Lion who is anything but. I must channel a little of this and a little of that. Above all, I will be a friend to Dorothy. I will be one of the good and wonderful characters of my child’s journey and not play the role that others are trying to cast upon me. I write my own role and no egregious preconditioning of my child need change me.

I am the person I am and I will continue to love my child unconditionally and continue to enforce our agreement to the letter, documenting and setting right many past violations that I should not have let slip by. I will wake up earlier, do better as a father, husband, employee and yes, even as an online personality. I am at great personal hardship moving closer to my child so I I now need to supplement my income if I am not to be destroyed financially by my upcoming hardships. Attempts to communicate this to my ex resulted in my child being brought into a conversation that was out of context, a violation of our agreement and just completely inappropriate and the began their shift in attitude towards me.

Well, it’s never too late to set things right. And so based on the same spirit of the momentum I created yesterday in rewriting my content management system, I will start using it to flesh-out my personal story and publish it here and on my YouTube videos. My stories are mine to tell and I will tell them. I have and continue to live a very full and interesting life. Even though I’ve gone through some interesting and difficult times including the collapse and betrayal of family and technology, my biggest challenges are clearly still ahead of me. Raising a child, righting my technological ways and telling my stories promises to be the best times of my life. I will shift my algorithm for living from the exploration of life to the enjoying of life. The book I read, Algorithms for Living, calls it the explore/exploit algorithm, but I think it ought to better be called explore/enjoy.

Hmmm, and so what next this morning? Documenting yesterday/last-night is certainly coming up but that’s not where my good and best morning energy should be funneled. That would be a defeat. I should finish out this blog entry and jump right back into where I left off yesterday. My content management system that builds off of Github Pages is first-past complete in terms of the rewrite. I have it processing each site I’m working on (such as this) with a keyboard press from within vim. The old version used to be very time-wasting in reprocessing every site with a master-script for all sites every time the keyboard macro was run. Per that last post… oops, it’s broken!

Time to fix. It’s never too late to fix. When something goes badly wrong, you first collect information. Collecting good information is the most important thing. What’s are the symptoms? Charlie Brown kicks at the football and winds up flat on his back. It’s not Lucy’s fault. Refer to the story of the Scorpion and the Frog. Stinging is just the scorpion’s nature, no matter what it tells the frog, and the frog should know that. Lucy is what she is and Charlie Brown should just know that and accommodate accordingly. So the first step is to see the situation clearly. Collect and record good information. Think it through out loud. Condition your mind to be a good football player, Charlie Brown!

When I use the keyboard shortcut from within vim, it blanks all the [site]/_posts content exactly as it should, but it doesn’t put the slice & diced new posts into location as it should. But the git commit and push works so the pages of the blog content disappear! Oops, that’s bad. I see the symptom of the problem, which reveals a lot about the problem itself. Let’s get this fixed in that good solid diagnostic way and feel good about myself, use it to get interesting parts of my story out there, and document my way to the next, good step, rinse and repeat! 1, 2, 3… 1? Better diagnostic output!

I dislike the current output from my new SSG CMS…

Yucky Output Poor For Diagnostics Fix Cli Command Line Interface

What’s wrong with this interface? No Figlet, hahaha! No, really I need to make this look good first. I need a big fat label.

And on the personal front, I need to a capture the most offending language:

Let me know if you don’t feel safe…

That’s planting subliminal suggestions that the child should be thinking of themselves as being in a situation where they don’t feel safe. That is a form of emotional abuse planting ideas like that over and over in a child’s head. Record the output. It is always important to have a record of the output. You can not prove to yourself and others the situation if you don’t have hard and fast evidence, so bank that evidence. Put it in a git repo and make sure that git repo is kept in a repository that is easily accessible on-demand.

And now look at the output. Organize, label and make it more useful for when it’s looked at later. Get organized! So you think a big, fat label is a silly thing? Compare the above output to this:

So the initial label really sets the mind. When you open an interaction with “Tell me when you don’t feel safe”, it sets the mind of the child. Don’t pretend like you don’t know what you’re doing. And so first we use a big, fat label to make the first interaction with a system work for us instead of against us.

First Headline Label Sets Mindset Interaction With System

Okay, all these hash-symbols when stuff is shown in the Linux terminal is actually markdown that shows as actual headlines, subheads, etc. in Jupyter but it’s working against me here. I’d be better off with an ALL-CAPS clear labeling system that keeps it small and readable on both sides. Fewer headlines! Less noise!

Here you can see my precision control of output in a Jupyter Notebook by showing the full absolute paths of my Python interpreter and other program that’s going to be invoked. Full, non-broken paths are always a good early step to making sure nothing breaks. Relative paths break. Absolute paths break less and reveal themselves as the problem more when they do. I also throw in a SystemExit() so all that stuff later in the script doesn’t try running. I do this with a SystemExit() so I can immediately test it Linux Terminal-side as well.

Precision Control Of Output Jupyter Notebook Figlet Paths Systemexit

And here is the same output Linux Terminal-side. See how nice Figlet is. You don’t think so, but it’s life-changing from a clarity-of-thought in software development point-of-view.

Nbdev Same Script From Jupyter But In Linux Terminal Using Figlet

Wow, okay I’m already getting the feeling that the problem is as good as fixed. I simply move the SystemExit() down little by little, improving the output of the script only showing what’s relevant, eliminating noise, adding signal and spotting what’s broken when I get to it. This is the way you do it in life too. It’s easy to make someone feel like something is broken beyond repair on you by sprinkling in symptoms here and there. It feels like a complex disorder, but if you catch it early enough and take preventative countermeasures, it’s really quite simple. Catch it early and don’t let it become complex!

Oops, change of plan! Instead of moving a SystemExit() progressively down the code for debugging, I am approaching a loop. A much better way to deal with progressive program-running allowance is to comment out large blocks of code. You do this in Jupyter Notebook (and JupyterLab, VSCode and various other text editors) by highlighting the block of code with your mouse and pressing Ctrl+Forward-slash. How do you even write this? Control Forward-slash? Ctrl+/. There’s no ideal way to explain keyboard combinations in English.

Python Commenting Out Large Blocks Of Code Ctrl Control Foward Slash

With the exception of the “Done” which is showing as an HTML H2, this output will be identical in Linux Terminal so no need to show it twice. That’s actually a big part of the goal here. Done is a good place to allow it to show as a ## Done Terminal-side because it doesn’t detract but looks great in Jupyter. Okay, so… I rarely use anything other than the default figlet font, Standard Medium, but this is a case where seeing what site you’re processing scroll by in glorious Figletease would be wonderful. But Standard Medium will be too big for these long sitenames. If you’re looking for a Figlet Font that’s readable yet small, Cybermedium is always a good bet.

Figlet Font Cybermedium Readable Yet Small

All this to diagnose and fix a problem? No! It’s more than just to diagnose and fix. It’s to make a wonderful show of it to help all others in the world facing similar problems while I do, for you see I’m a very generous and pedantic person. I both have the excess time to put on such a show, having this Father’s Day weekend to myself as I do, and I have the ability and excess capacity to put on such a show, having put in my 10-years / 10,000 hours of practice on tools such as Linux, Python, vim & git such as I have. Plus, it makes problem-solving fun!

Next!

Hmm, let’s show the nice people all the code so far:

# export

import os
import sys
import shlex
import argparse
import pandas as pd
from git import Repo
from pathlib import Path
from art import text2art
from collections import namedtuple
from subprocess import Popen, PIPE


if os.name == "nt":
    git_exe = r"C:\Program Files\Git\cmd\git.exe"
else:
    git_exe = "/usr/bin/git"
os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = git_exe

lr = "\n"
python = sys.executable
home = Path(os.path.expanduser("~"))
blogslicer = Path(home / Path("github/blogslicer/blogslicer/core.py"))
if hasattr(__builtins__, "__IPYTHON__") or __name__ != "__main__":
    is_jupyter = True
    from IPython.display import display, Markdown, HTML

    h1 = lambda text: display(Markdown(f"# {text}"))
    h2 = lambda text: display(Markdown(f"## {text}"))
    h3 = lambda text: display(Markdown(f"### {text}"))
    file = "sites.csv"
    # apex = "/mnt/c/Users/mikle/github/MikeAtEleven.com"
    apex = ""
else:
    is_jupyter = False
    h1 = lambda text: print(f"# {text}")
    h2 = lambda text: print(f"## {text}")
    h3 = lambda text: print(f"### {text}")
    aparser = argparse.ArgumentParser()
    add_arg = aparser.add_argument
    add_arg("-f", "--file", required=True)
    add_arg("-x", "--apex", required=False)
    args = aparser.parse_args()
    file = args.file
    apex = args.apex


def fig(text, font="Standard"):
    if is_jupyter:
        display(
            HTML(
                f'<pre style="white-space: pre;">{text2art(text, font=font).replace(lr, "<br/>")}</pre>'
            )
        )
    else:
        print(text2art(text, font))


fig("Making Sites...")

file_obj = Path(file)
df = pd.read_csv(file_obj, delimiter="|")
df = df.applymap(lambda x: x.strip())
df.columns = [x.strip() for x in df.columns]
if apex:
    apex = Path(apex).name
    df = df[df["apex"] == apex]
Site = namedtuple("Site", "path, apex, title, gaid, tagline")


def git(cwd, args):
    cmd = [git_exe] + shlex.split(args)
    h2(f"git cmd: {shlex.join(cmd)}")
    process = Popen(
        args=cmd,
        cwd=cwd,
        stdout=PIPE,
        stderr=PIPE,
        shell=False,
        bufsize=1,
        universal_newlines=True,
    )
    h3("git stdout")
    for line in process.stdout:
        print(line.strip())
        sys.stdout.flush()
    print()
    h3("git stderr")
    for line in process.stderr:
        print(line.strip())
        sys.stdout.flush()
    print()


print(f"INTERPRETER: {python}")
print(f"SLICER: {blogslicer}")

for index, series in df.iterrows():
    site = Site(**series.to_dict())
    fig(site.apex, font="Cybermedium")
    here = Path(home / site.path)
    print(f"PATH: {here}")
    # [x.unlink() for x in Path(here / "_posts/").glob("*")]

#     # Blog Slicer
#     cmd = f'{python} {blogslicer} -p {here} -t "{site.title}" -s "blog" -a "Mike Levin"'
#     print(cmd, end="\n\n")
#     with Popen(args=cmd, cwd=here, stdout=PIPE, stderr=PIPE, shell=True) as pout:
#         for line in pout.stdout.readlines():
#             print(line.decode().strip())

#     git(here, "add _posts/*")
#     git(here, 'commit -am "Publising Blog Posts"')
#     git(here, "push")

h2("Done!")

This way they can see the figlet function and how I’m commenting out the blocks of code and progressively activating lines to debug. I’ll also be improving the git function output.

It’s also worth pointing out that when you work this way in Jupyter, you’re actually trying to keep your function usage to a minimum to keep the lovely exploratory coding environment of Jupyter’s REPL (read, eval, print loop) working the way it should. All code inside functions takes things “out-of-flow”. Like a good story, a good script should read from top-down, telling a story and having a logical flow. Functions interrupt this flow and make debugging more challenging. So as you can see, I turned both figlet and git into functions… because they should be and not because someone is chasing me with a stick telling me to turn everything into functions.

Okay, so now this next step is a hoot! It’s the construction of the absolute-path command to do the blog-slicing. It re-populates the [site]_posts folder for each site. It’s also highly OS-dependent so I can’t copy/paste one of these commands from Juptyer-side and expect it to run in the Linux Terminal. I’d have to run the core.py file in the Linux Terminal and copy-paste a command from there back into the Linux terminal. And that’s exactly what I’m going to do!

One Python Script Calling Another From Jupyter Absolute Paths Os Dependent

Here’s the program output in Linux Terminal. Notice that even absolute paths are OS independent when constructed with pathlib in Python. Think about that. This is absolutely amazing. I don’t need to purge Windows Jupyter Desktop out of my process yet because Python itself is an OS-independence layer when used well.

Absolute Paths Are Os Independent When Constructed With Pathlib In Python

People live in fear of difficult problems. They feel they are not up to them. They become reclusive, not wanting to step out into the purview of a Great and Powerful Wizard, even though it’s just a man behind a curtain. The real brave ones like the Lion are made to feel cowardly because they’re told they are, but what’s inside belies the truth. The Scarecrow is the really intelligent one, always using his intellect but not giving himself credit. And who has more heart than the Tin Woodman?

NO! No, I say! Step out into the center of the room and announce yourself to the great and powerful humbug! Humbug, I tell you! I call you out on your humbug and my own genuine wizardly talents supersedes yours. Take that!

Okay, think! Think, Scarecrow. Copy/paste one of the Linux-side blogslicer commands. Look at the output.

I Caught Myself A Woogle Bug Gotcha Debug Python

I caught myself a woogle bug! LOL, Gotcha! Sheesh, debugging Python can be so easy if you’re just not calling one program from another through the Unix / Linux API… my own fault.

Still, I love the design of my program and going through this debugging exercise was very much worth it for the lessons in cleaning up program output and keeping meticulous pedantic records.

Alright, I caught the bug and I’m also doing a good bit of cleanup in blogslicer. It doesn’t need all the headline stuff. Trim it down. Blogslicer is about as trimmed down as I can make it, just outputting the list of files it generated with absolute paths. This looks very nice inline with the Figlet labels:

 __  __         _     _                 ____   _  _
|  \/  |  __ _ | | __(_) _ __    __ _  / ___| (_)| |_   ___  ___
| |\/| | / _` || |/ /| || '_ \  / _` | \___ \ | || __| / _ \/ __|
| |  | || (_| ||   < | || | | || (_| |  ___) || || |_ |  __/\__ \ _  _  _
|_|  |_| \__,_||_|\_\|_||_| |_| \__, | |____/ |_| \__| \___||___/(_)(_)(_)
                                |___/

INTERPRETER: /home/healus/py310/bin/python
SLICER: /home/healus/github/blogslicer/blogslicer/core.py
____ _  _ ____ ____ _ _    _    ____ ___ ____ ____ _  _  ____ ____ _  _
| __ |  | |___ |__/ | |    |    |__|  |  |___ |    |__|  |    |  | |\/|
|__] |__| |___ |  \ | |___ |___ |  |  |  |___ |___ |  | .|___ |__| |  |


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/GuerillaTech.com -t "Guerilla Tech" -s "blog" -a "Mike Levin"

/home/healus/github/GuerillaTech.com/_posts/2022-04-22-post-1.md
_    ____ _  _ _ _  _ _  _ _  _  ____ ____ _  _
|    |___ |  | | |\ | |  |  \/   |    |  | |\/|
|___ |___  \/  | | \| |__| _/\_ .|___ |__| |  |


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/Levinux.com -t "Levinux" -s "blog" -a "Mike Levin"

/home/healus/github/Levinux.com/_posts/1970-01-01-post-1.md
_    _ _  _ _  _ _  _ ___  _   _ ___ _  _ ____ _  _ _  _ _ _  _ ____ _ ___  ____ ____ _  _
|    | |\ | |  |  \/  |__]  \_/   |  |__| |  | |\ | |  | | |\/| | __ |  |   |    |  | |\/|
|___ | | \| |__| _/\_ |      |    |  |  | |__| | \|  \/  | |  | |__] |  |  .|___ |__| |  |


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/LinuxPythonvimgit.com -t "Linux, Python, vim & git" -s "blog" -a "Mike Levin"

/home/healus/github/LinuxPythonvimgit.com/_posts/2022-05-21-post-6.md
/home/healus/github/LinuxPythonvimgit.com/_posts/2022-05-21-post-5.md
/home/healus/github/LinuxPythonvimgit.com/_posts/2022-05-20-post-4.md
/home/healus/github/LinuxPythonvimgit.com/_posts/2022-05-02-post-3.md
/home/healus/github/LinuxPythonvimgit.com/_posts/2022-05-01-post-2.md
/home/healus/github/LinuxPythonvimgit.com/_posts/2022-04-21-post-1.md
_    _  _ _  _ ___  ____ ____ _  _ ____ _  _ ___   ____ ____ _  _
|    |  | |\ | |  \ |___ |__/ |  | |__| |\ | |  \  |    |  | |\/|
|___ |__| | \| |__/ |___ |  \  \/  |  | | \| |__/ .|___ |__| |  |


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/LunderVand.com -t "LunderVand" -s "blog" -a "Mike Levin"

/home/healus/github/LunderVand.com/_posts/2022-04-22-post-1.md
_  _ _ _  _ ____    _    ____ _  _ _ _  _  ____ ____ _  _
|\/| | |_/  |___ __ |    |___ |  | | |\ |  |    |  | |\/|
|  | | | \_ |___    |___ |___  \/  | | \| .|___ |__| |  |


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/Mike-Levin.com -t "Mike Levin Dot Com" -s "blog" -a "Mike Levin"

/home/healus/github/Mike-Levin.com/_posts/2022-04-22-post-1.md
_  _ _ _  _ ____ ____ ___ ____ _    ____ _  _ ____ _  _  ____ ____ _  _
|\/| | |_/  |___ |__|  |  |___ |    |___ |  | |___ |\ |  |    |  | |\/|
|  | | | \_ |___ |  |  |  |___ |___ |___  \/  |___ | \| .|___ |__| |  |


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/MikeAtEleven.com -t "Mike At Eleven" -s "blog" -a "Mike Levin"

/home/healus/github/MikeAtEleven.com/_posts/2022-06-06-post-23.md
/home/healus/github/MikeAtEleven.com/_posts/2022-06-05-post-22.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-07-post-21.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-06-post-20.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-05-post-19.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-04-post-18.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-04-post-17.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-04-post-16.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-04-post-15.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-04-post-14.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-04-post-13.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-04-post-12.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-03-post-11.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-03-post-10.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-03-post-9.md
/home/healus/github/MikeAtEleven.com/_posts/2022-05-02-post-8.md
/home/healus/github/MikeAtEleven.com/_posts/2022-04-20-post-7.md
/home/healus/github/MikeAtEleven.com/_posts/2021-09-02-post-6.md
/home/healus/github/MikeAtEleven.com/_posts/2021-08-26-post-5.md
/home/healus/github/MikeAtEleven.com/_posts/2021-08-24-post-4.md
/home/healus/github/MikeAtEleven.com/_posts/2021-08-23-post-3.md
/home/healus/github/MikeAtEleven.com/_posts/2021-08-22-post-2.md
/home/healus/github/MikeAtEleven.com/_posts/2021-08-20-post-1.md
_  _ _ _  _ ____ _    ____ _  _  _ _  _
|\/| | |_/  |___ |    |___ |  |  | |\ |
|  | | | \_ |___ |___ |___  \/  .| | \|


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/MikeLev.in -t "Mike Levin" -s "blog" -a "Mike Levin"

/home/healus/github/MikeLev.in/_posts/2022-06-18-post-140.md
/home/healus/github/MikeLev.in/_posts/2022-06-17-post-139.md
/home/healus/github/MikeLev.in/_posts/2022-06-16-post-138.md
/home/healus/github/MikeLev.in/_posts/2022-06-16-post-137.md
/home/healus/github/MikeLev.in/_posts/2022-06-15-post-136.md
/home/healus/github/MikeLev.in/_posts/2022-06-15-post-135.md
/home/healus/github/MikeLev.in/_posts/2022-06-15-post-134.md
/home/healus/github/MikeLev.in/_posts/2022-06-15-post-133.md
/home/healus/github/MikeLev.in/_posts/2022-06-14-post-132.md
/home/healus/github/MikeLev.in/_posts/2022-06-14-post-131.md
/home/healus/github/MikeLev.in/_posts/2022-06-14-post-130.md
/home/healus/github/MikeLev.in/_posts/2022-06-13-post-129.md
/home/healus/github/MikeLev.in/_posts/2022-06-12-post-128.md
/home/healus/github/MikeLev.in/_posts/2022-06-11-post-127.md
/home/healus/github/MikeLev.in/_posts/2022-06-10-post-126.md
/home/healus/github/MikeLev.in/_posts/2022-06-10-post-125.md
/home/healus/github/MikeLev.in/_posts/2022-06-09-post-124.md
/home/healus/github/MikeLev.in/_posts/2022-06-09-post-123.md
/home/healus/github/MikeLev.in/_posts/2022-06-08-post-122.md
/home/healus/github/MikeLev.in/_posts/2022-06-08-post-121.md
/home/healus/github/MikeLev.in/_posts/2022-06-08-post-120.md
/home/healus/github/MikeLev.in/_posts/2022-06-07-post-119.md
/home/healus/github/MikeLev.in/_posts/2022-06-07-post-118.md
/home/healus/github/MikeLev.in/_posts/2022-06-07-post-117.md
/home/healus/github/MikeLev.in/_posts/2022-06-03-post-116.md
/home/healus/github/MikeLev.in/_posts/2022-06-01-post-115.md
/home/healus/github/MikeLev.in/_posts/2022-06-01-post-114.md
/home/healus/github/MikeLev.in/_posts/2022-05-31-post-113.md
/home/healus/github/MikeLev.in/_posts/2022-05-31-post-112.md
/home/healus/github/MikeLev.in/_posts/2022-05-31-post-111.md
/home/healus/github/MikeLev.in/_posts/2022-05-30-post-110.md
/home/healus/github/MikeLev.in/_posts/2022-05-30-post-109.md
/home/healus/github/MikeLev.in/_posts/2022-05-29-post-108.md
/home/healus/github/MikeLev.in/_posts/2022-05-29-post-107.md
/home/healus/github/MikeLev.in/_posts/2022-05-28-post-106.md
/home/healus/github/MikeLev.in/_posts/2022-05-28-post-105.md
/home/healus/github/MikeLev.in/_posts/2022-05-27-post-104.md
/home/healus/github/MikeLev.in/_posts/2022-05-26-post-103.md
/home/healus/github/MikeLev.in/_posts/2022-05-26-post-102.md
/home/healus/github/MikeLev.in/_posts/2022-05-25-post-101.md
/home/healus/github/MikeLev.in/_posts/2022-05-25-post-100.md
/home/healus/github/MikeLev.in/_posts/2022-05-25-post-99.md
/home/healus/github/MikeLev.in/_posts/2022-05-23-post-98.md
/home/healus/github/MikeLev.in/_posts/2022-05-23-post-97.md
/home/healus/github/MikeLev.in/_posts/2022-05-22-post-96.md
/home/healus/github/MikeLev.in/_posts/2022-05-21-post-95.md
/home/healus/github/MikeLev.in/_posts/2022-05-20-post-94.md
/home/healus/github/MikeLev.in/_posts/2022-05-20-post-93.md
/home/healus/github/MikeLev.in/_posts/2022-05-19-post-92.md
/home/healus/github/MikeLev.in/_posts/2022-05-19-post-91.md
/home/healus/github/MikeLev.in/_posts/2022-05-19-post-90.md
/home/healus/github/MikeLev.in/_posts/2022-05-18-post-89.md
/home/healus/github/MikeLev.in/_posts/2022-05-18-post-88.md
/home/healus/github/MikeLev.in/_posts/2022-05-18-post-87.md
/home/healus/github/MikeLev.in/_posts/2022-05-17-post-86.md
/home/healus/github/MikeLev.in/_posts/2022-05-17-post-85.md
/home/healus/github/MikeLev.in/_posts/2022-05-16-post-84.md
/home/healus/github/MikeLev.in/_posts/2022-05-16-post-83.md
/home/healus/github/MikeLev.in/_posts/2022-05-16-post-82.md
/home/healus/github/MikeLev.in/_posts/2022-05-15-post-81.md
/home/healus/github/MikeLev.in/_posts/2022-05-13-post-80.md
/home/healus/github/MikeLev.in/_posts/2022-05-13-post-79.md
/home/healus/github/MikeLev.in/_posts/2022-05-13-post-78.md
/home/healus/github/MikeLev.in/_posts/2022-05-13-post-77.md
/home/healus/github/MikeLev.in/_posts/2022-05-13-post-76.md
/home/healus/github/MikeLev.in/_posts/2022-05-11-post-75.md
/home/healus/github/MikeLev.in/_posts/2022-05-10-post-74.md
/home/healus/github/MikeLev.in/_posts/2022-05-10-post-73.md
/home/healus/github/MikeLev.in/_posts/2022-05-08-post-72.md
/home/healus/github/MikeLev.in/_posts/2022-05-08-post-71.md
/home/healus/github/MikeLev.in/_posts/2022-05-08-post-70.md
/home/healus/github/MikeLev.in/_posts/2022-05-07-post-69.md
/home/healus/github/MikeLev.in/_posts/2022-05-07-post-68.md
/home/healus/github/MikeLev.in/_posts/2022-05-07-post-67.md
/home/healus/github/MikeLev.in/_posts/2022-05-07-post-66.md
/home/healus/github/MikeLev.in/_posts/2022-05-06-post-65.md
/home/healus/github/MikeLev.in/_posts/2022-05-06-post-64.md
/home/healus/github/MikeLev.in/_posts/2022-05-05-post-63.md
/home/healus/github/MikeLev.in/_posts/2022-05-05-post-62.md
/home/healus/github/MikeLev.in/_posts/2022-05-05-post-61.md
/home/healus/github/MikeLev.in/_posts/2022-05-05-post-60.md
/home/healus/github/MikeLev.in/_posts/2022-05-04-post-59.md
/home/healus/github/MikeLev.in/_posts/2022-05-04-post-58.md
/home/healus/github/MikeLev.in/_posts/2022-05-04-post-57.md
/home/healus/github/MikeLev.in/_posts/2022-05-04-post-56.md
/home/healus/github/MikeLev.in/_posts/2022-05-03-post-55.md
/home/healus/github/MikeLev.in/_posts/2022-05-02-post-54.md
/home/healus/github/MikeLev.in/_posts/2022-05-02-post-53.md
/home/healus/github/MikeLev.in/_posts/2022-05-02-post-52.md
/home/healus/github/MikeLev.in/_posts/2022-05-01-post-51.md
/home/healus/github/MikeLev.in/_posts/2022-05-01-post-50.md
/home/healus/github/MikeLev.in/_posts/2022-05-01-post-49.md
/home/healus/github/MikeLev.in/_posts/2022-05-01-post-48.md
/home/healus/github/MikeLev.in/_posts/2022-05-01-post-47.md
/home/healus/github/MikeLev.in/_posts/2022-05-01-post-46.md
/home/healus/github/MikeLev.in/_posts/2022-05-01-post-45.md
/home/healus/github/MikeLev.in/_posts/2022-05-01-post-44.md
/home/healus/github/MikeLev.in/_posts/2022-04-30-post-43.md
/home/healus/github/MikeLev.in/_posts/2022-04-30-post-42.md
/home/healus/github/MikeLev.in/_posts/2022-04-30-post-41.md
/home/healus/github/MikeLev.in/_posts/2022-04-30-post-40.md
/home/healus/github/MikeLev.in/_posts/2022-04-30-post-39.md
/home/healus/github/MikeLev.in/_posts/2022-04-29-post-38.md
/home/healus/github/MikeLev.in/_posts/2022-04-29-post-37.md
/home/healus/github/MikeLev.in/_posts/2022-04-29-post-36.md
/home/healus/github/MikeLev.in/_posts/2022-04-29-post-35.md
/home/healus/github/MikeLev.in/_posts/2022-04-28-post-34.md
/home/healus/github/MikeLev.in/_posts/2022-04-27-post-33.md
/home/healus/github/MikeLev.in/_posts/2022-04-27-post-32.md
/home/healus/github/MikeLev.in/_posts/2022-04-26-post-31.md
/home/healus/github/MikeLev.in/_posts/2022-04-26-post-30.md
/home/healus/github/MikeLev.in/_posts/2022-04-25-post-29.md
/home/healus/github/MikeLev.in/_posts/2022-04-23-post-28.md
/home/healus/github/MikeLev.in/_posts/2022-04-23-post-27.md
/home/healus/github/MikeLev.in/_posts/2022-04-22-post-26.md
/home/healus/github/MikeLev.in/_posts/2022-04-22-post-25.md
/home/healus/github/MikeLev.in/_posts/2022-04-21-post-24.md
/home/healus/github/MikeLev.in/_posts/2022-04-21-post-23.md
/home/healus/github/MikeLev.in/_posts/2022-04-15-post-22.md
/home/healus/github/MikeLev.in/_posts/2022-04-15-post-21.md
/home/healus/github/MikeLev.in/_posts/2022-04-13-post-20.md
/home/healus/github/MikeLev.in/_posts/2022-04-10-post-19.md
/home/healus/github/MikeLev.in/_posts/2022-04-09-post-18.md
/home/healus/github/MikeLev.in/_posts/2022-04-08-post-17.md
/home/healus/github/MikeLev.in/_posts/2022-04-07-post-16.md
/home/healus/github/MikeLev.in/_posts/2022-02-21-post-15.md
/home/healus/github/MikeLev.in/_posts/2022-02-18-post-14.md
/home/healus/github/MikeLev.in/_posts/2022-02-17-post-13.md
/home/healus/github/MikeLev.in/_posts/2022-02-16-post-12.md
/home/healus/github/MikeLev.in/_posts/2022-02-15-post-11.md
/home/healus/github/MikeLev.in/_posts/2021-11-14-post-10.md
/home/healus/github/MikeLev.in/_posts/2021-08-30-post-9.md
/home/healus/github/MikeLev.in/_posts/2021-08-26-post-8.md
/home/healus/github/MikeLev.in/_posts/2021-08-24-post-7.md
/home/healus/github/MikeLev.in/_posts/2021-08-20-post-6.md
/home/healus/github/MikeLev.in/_posts/2021-08-20-post-5.md
/home/healus/github/MikeLev.in/_posts/2021-08-20-post-4.md
/home/healus/github/MikeLev.in/_posts/2021-08-06-post-3.md
/home/healus/github/MikeLev.in/_posts/2021-08-05-post-2.md
_  _ _ _  _ ____ _    ____ _  _ _ _  _ ____ ____ ____  ____ ____ _  _
|\/| | |_/  |___ |    |___ |  | | |\ | [__  |___ |  |  |    |  | |\/|
|  | | | \_ |___ |___ |___  \/  | | \| ___] |___ |__| .|___ |__| |  |


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/MikeLevinSEO.com -t "Mike Levin SEO" -s "blog" -a "Mike Levin"

___  _ ___  _  _ _    ____ ___ ____  ____ ____ _  _
|__] | |__] |  | |    |__|  |  |___  |    |  | |\/|
|    | |    |__| |___ |  |  |  |___ .|___ |__| |  |


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/Pipulate.com -t "Pipulate" -s "blog" -a "Mike Levin"

/home/healus/github/Pipulate.com/_posts/2022-04-22-post-1.md
___  _   _ ___ _  _ ____ _  _ _ ____ ____ _    _    _   _  ____ ____ _  _
|__]  \_/   |  |__| |  | |\ | | |    |__| |    |     \_/   |    |  | |\/|
|      |    |  |  | |__| | \| | |___ |  | |___ |___   |   .|___ |__| |  |


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/PythonicAlly.com -t "Pythonically" -s "blog" -a "Mike Levin"

/home/healus/github/PythonicAlly.com/_posts/2022-04-28-post-1.md
___  _   _ ___ _  _ ____ _  _ _ ____ ____ _    _    _   _  ____ ____ ____
|__]  \_/   |  |__| |  | |\ | | |    |__| |    |     \_/   |  | |__/ | __
|      |    |  |  | |__| | \| | |___ |  | |___ |___   |   .|__| |  \ |__]


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/PythonicAlly.org -t "Your Pythonic Ally" -s "blog" -a "Mike Levin"

/home/healus/github/PythonicAlly.org/_posts/1970-01-01-post-1.md
____ ____ _  _ ____ _  _ ____ ___  _    ____ ____ _ _  _ ____ ____ ____  ____ ____ _  _
|__/ |___ |\/| |  | |  | |__| |__] |    |___ |___ | |\ | | __ |___ |__/  |    |  | |\/|
|  \ |___ |  | |__|  \/  |  | |__] |___ |___ |    | | \| |__] |___ |  \ .|___ |__| |  |


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/RemovableFinger.com -t "Removable Finger" -s "blog" -a "Mike Levin"

/home/healus/github/RemovableFinger.com/_posts/2022-05-01-post-1.md
___ ____ ____ ___  _ ____ ____ ____ ___  ____ ____ _ ____ ____ _  _ ____  ____ ____ _  _
 |  |__| |__/ |  \ | | __ |__/ |__| |  \ |___ |    | |__/ |    |  | [__   |    |  | |\/|
 |  |  | |  \ |__/ | |__] |  \ |  | |__/ |___ |___ | |  \ |___ |__| ___] .|___ |__| |  |


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/TardigradeCircus.com -t "Tardigrade Circus" -s "blog" -a "Mike Levin"

/home/healus/github/TardigradeCircus.com/_posts/2022-04-22-post-1.md
___ _ ____ ___ ____ ____ _  _ ____ ____ ____ _ ____ _  _ ___ _ _  _ ____ ____  ____ ____ _  _
 |  | |     |  |__| |    |  | |___ |  | [__  | | __ |__|  |  | |\ | | __ [__   |    |  | |\/|
 |  | |___  |  |  | |___ |__| |    |__| ___] | |__] |  |  |  | | \| |__] ___] .|___ |__| |  |


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/TicTacUFOSightings.com -t "Tic Tac UFO Sightings" -s "blog" -a "Mike Levin"

/home/healus/github/TicTacUFOSightings.com/_posts/1970-01-01-post-1.md
_ _ _ ____ ____ _  _ _    _   _ ____ ____ ___  ____ ____ ___ ____  ___  ___
| | | |___ |___ |_/  |     \_/  |__/ |___ |__] |  | |__/  |  [__     /  |  \
|_|_| |___ |___ | \_ |___   |   |  \ |___ |    |__| |  \  |  ___] . /__ |__/


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/WeeklyReports.zd -t "Mike Levin's Weekly Reports" -s "blog" -a "Mike Levin"

/home/healus/github/WeeklyReports.zd/_posts/2022-05-07-post-2.md
/home/healus/github/WeeklyReports.zd/_posts/2022-05-14-post-1.md
_ _ _ _  _ ____ ___ ____ ____ _  _ ____ ___ ____ ____ ____ ____  _ ____
| | | |__| |__|  |  [__  |__| |\/| |___  |  |__| |___ |  | |__/  | |  |
|_|_| |  | |  |  |  ___] |  | |  | |___  |  |  | |    |__| |  \ .| |__|


/home/healus/py310/bin/python /home/healus/github/blogslicer/blogslicer/core.py -p /home/healus/github/WhatsaMetaFor.io -t "What's A Meta For" -s "blog" -a "Mike Levin"

/home/healus/github/WhatsaMetaFor.io/_posts/2022-05-07-post-4.md
/home/healus/github/WhatsaMetaFor.io/_posts/2022-05-06-post-3.md
/home/healus/github/WhatsaMetaFor.io/_posts/2022-05-03-post-2.md
/home/healus/github/WhatsaMetaFor.io/_posts/2022-04-30-post-1.md
## Done!

Very nice.

The last thing is all that ugly git output, not knowing when to show stdout and when to show stderr.

I’ve done an excellent job so far on this fixing of this bug and improving the output from the program. I think it’s even going to play well online. I can’t wait to talk people through this post. Currently the only issues left are how git displays and actually adding a new folder to the git commit to the release process.

Okay, and now finally it’s done. I have the assets/images/* folder being added every time. It makes this post look correct and now any journal.md file I’m editing in vim is one @l away from being published.

# export

import os
import sys
import shlex
import argparse
import pandas as pd
from git import Repo
from pathlib import Path
from art import text2art
from collections import namedtuple
from subprocess import Popen, PIPE


if os.name == "nt":
    git_exe = r"C:\Program Files\Git\cmd\git.exe"
else:
    git_exe = "/usr/bin/git"
os.environ["GIT_PYTHON_GIT_EXECUTABLE"] = git_exe

lr = "\n"
python = sys.executable
home = Path(os.path.expanduser("~"))
blogslicer = Path(home / Path("github/blogslicer/blogslicer/core.py"))
if hasattr(__builtins__, "__IPYTHON__") or __name__ != "__main__":
    is_jupyter = True
    from IPython.display import display, Markdown, HTML

    h1 = lambda text: display(Markdown(f"# {text}"))
    h2 = lambda text: display(Markdown(f"## {text}"))
    h3 = lambda text: display(Markdown(f"### {text}"))
    file = "sites.csv"
    # apex = "/mnt/c/Users/mikle/github/MikeAtEleven.com"
    apex = ""
else:
    is_jupyter = False
    h1 = lambda text: print(f"# {text}")
    h2 = lambda text: print(f"## {text}")
    h3 = lambda text: print(f"### {text}")
    aparser = argparse.ArgumentParser()
    add_arg = aparser.add_argument
    add_arg("-f", "--file", required=True)
    add_arg("-x", "--apex", required=False)
    args = aparser.parse_args()
    file = args.file
    apex = args.apex


def fig(text, font="Standard"):
    if is_jupyter:
        display(
            HTML(
                f'<pre style="white-space: pre;">{text2art(text, font=font).replace(lr, "<br/>")}</pre>'
            )
        )
    else:
        print(text2art(text, font))


fig("Making Sites...")

file_obj = Path(file)
df = pd.read_csv(file_obj, delimiter="|")
df = df.applymap(lambda x: x.strip())
df.columns = [x.strip() for x in df.columns]
if apex:
    apex = Path(apex).name
    df = df[df["apex"] == apex]
Site = namedtuple("Site", "path, apex, title, gaid, tagline")


def flush(std):
    for line in std:
        line = line.strip()
        if line:
            print(line)
            sys.stdout.flush()


def git(cwd, args):
    cmd = [git_exe] + shlex.split(args)
    print()
    print(f"<< {shlex.join(cmd)} >>")
    process = Popen(
        args=cmd,
        cwd=cwd,
        stdout=PIPE,
        stderr=PIPE,
        shell=False,
        bufsize=1,
        universal_newlines=True,
    )
    flush(process.stdout)
    flush(process.stderr)


print(f"INTERPRETER: << {python} >>")
print(f"SLICER: << {blogslicer} >>")

for index, series in df.iterrows():
    site = Site(**series.to_dict())
    fig(site.apex, font="Cybermedium")
    here = Path(home / site.path)
    [x.unlink() for x in Path(here / "_posts/").glob("*")]

    cmd = f'{python} {blogslicer} -p {here} -t "{site.title}" -s "blog" -a "Mike Levin"'
    print(cmd, end="\n\n")
    with Popen(args=cmd, cwd=here, stdout=PIPE, stderr=PIPE, shell=True) as pout:
        for line in pout.stdout.readlines():
            print(line.decode().strip())

    git(here, "add _posts/*")
    git(here, "add assets/images/*")
    git(here, 'commit -am "Publising Blog Posts"')
    git(here, "push")

h2("Done!")

Category: My Static Site Generator (Skite)