Skip to content

Commit

Permalink
Black Code Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 18, 2022
1 parent fa0a798 commit 0c4df4a
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 55 deletions.
26 changes: 20 additions & 6 deletions LjinuxRoot/bin/echo.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
try:
optss = ljinux.based.fn.get_valid_options(ljinux.based.user_vars["argj"].split()[1], "ne")
optss = ljinux.based.fn.get_valid_options(
ljinux.based.user_vars["argj"].split()[1], "ne"
)
offs = 0
if len(optss) > 0:
offs += 1
if ljinux.based.user_vars["argj"].split()[1 + offs].startswith('"'):
if ljinux.based.user_vars["argj"].split()[1 + offs].endswith('"'):
if not ljinux.based.silent:
print(str(ljinux.based.user_vars["argj"].split()[1 + offs])[1:-1])
ljinux.based.user_vars["return"] = str(ljinux.based.user_vars["argj"].split()[1 + offs])[1:-1]
ljinux.based.user_vars["return"] = str(
ljinux.based.user_vars["argj"].split()[1 + offs]
)[1:-1]
else:
countt = len(ljinux.based.user_vars["argj"].split()) - offs
if countt > 2:
if ljinux.based.user_vars["argj"].split()[countt - 1 + offs].endswith('"'):
res = str(ljinux.based.user_vars["argj"].split()[1 + offs])[1:] + " "
if (
ljinux.based.user_vars["argj"]
.split()[countt - 1 + offs]
.endswith('"')
):
res = (
str(ljinux.based.user_vars["argj"].split()[1 + offs])[1:] + " "
)
for i in range(2, countt - 1):
res += ljinux.based.user_vars["argj"].split()[i + offs] + " "
res += str(ljinux.based.user_vars["argj"].split()[countt - 1 + offs])[:-1]
res += str(
ljinux.based.user_vars["argj"].split()[countt - 1 + offs]
)[:-1]
if not ljinux.based.silent:
if "n" in optss:
print(res, end="")
Expand All @@ -30,7 +42,9 @@
pass
else:
try:
res = ljinux.based.fn.adv_input(ljinux.based.user_vars["argj"].split()[1], str)
res = ljinux.based.fn.adv_input(
ljinux.based.user_vars["argj"].split()[1], str
)
if not ljinux.based.silent:
print(res)
ljinux.based.user_vars["return"] = res
Expand Down
103 changes: 59 additions & 44 deletions ljinux_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,12 @@ def load(filen):
with open(filen, "r") as historyfile:
lines = historyfile.readlines()
for line in lines:
ljinux.io.ledset(3) # act
ljinux.io.ledset(3) # act
ljinux.history.historyy.append(line.strip())
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle

except OSError:
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle
ljinux.based.error(4, filen)

def appen(itemm): # add to history, but don't save to file
Expand Down Expand Up @@ -528,7 +528,7 @@ def main_tick(loud=False): # this run in between of shell character captures

class io:
# activity led

ledcases = {
0: nc.off,
1: nc.idle,
Expand All @@ -538,14 +538,14 @@ class io:
5: nc.error,
6: nc.killtheuser,
}

led = digitalio.DigitalInOut(boardLED)
led.direction = digitalio.Direction.OUTPUT
if configg["ledtype"] == "generic":
led.value = True
elif configg["ledtype"] == "neopixel":
neopixel_write(led, nc.idle)

# sd card
# L R and Enter keys for basic io
buttonl = digitalio.DigitalInOut(board.GP19)
Expand All @@ -558,15 +558,15 @@ class io:
network_online = False
network_name = "Offline"

def ledset(state): # Set the led to a state
def ledset(state): # Set the led to a state
if configg["ledtype"] == "generic":
if state in [0, 3]:
ljinux.io.led.value = False
else:
ljinux.io.led.value = True
elif configg["ledtype"] == "neopixel":
neopixel_write(ljinux.io.led, ljinux.io.ledcases[state])

def get_static_file(filename, m="rb"):
"Static file generator"
try:
Expand Down Expand Up @@ -836,8 +836,8 @@ def error(wh=3, f=None):
ljinux.based.error([number])
where [number] is one of the error below
"""
ljinux.io.ledset(5) # error
time.sleep(.1)
ljinux.io.ledset(5) # error
time.sleep(0.1)
errs = {
1: "Syntax Error",
2: "Input Error",
Expand All @@ -848,14 +848,14 @@ def error(wh=3, f=None):
7: "Filesystem unwritable, pi in developer mode",
8: "Missing files",
9: "Missing arguments",
10: "File exists"
10: "File exists",
}
print("based: " + errs[wh])
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle
del errs

def autorun():
ljinux.io.ledset(3) # act
ljinux.io.ledset(3) # act
global Exit
global Exit_code
global Version
Expand Down Expand Up @@ -885,7 +885,7 @@ def autorun():
)
del modules["adafruit_sdcard"]
dmtex("Unloaded sdio libraries")
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle
systemprints(
2,
"Running Init Script",
Expand All @@ -897,7 +897,7 @@ def autorun():
lines = None
Exit_code = 0 # resetting, in case we are the 2nd .shell
try:
ljinux.io.ledset(3) # act
ljinux.io.ledset(3) # act
ljinux.based.command.execc(["/LjinuxRoot/boot/Init.lja"])
systemprints(1, "Running Init Script")
except OSError:
Expand Down Expand Up @@ -976,7 +976,7 @@ def autorun():
print("based: Caught Ctrl + C")
else:
print("based: Init-type specified incorrectly, assuming oneshot")
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle
while not Exit:
try:
ljinux.based.shell()
Expand All @@ -996,30 +996,32 @@ def execc(argj): # exec a based script
if argj[0] == "exec":
argj = argj[1:] # we don't want to carry on the exec command itself
try:
ljinux.io.ledset(3) # act
ljinux.io.ledset(3) # act
f = open(argj[0], "r") # open the file to run
lines = f.readlines() # get all lines
count = 0
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle
for line in lines:
ljinux.io.ledset(3) # act
ljinux.io.ledset(3) # act
lines[count] = line.strip() # command_split
count += 1
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle
simplif = ""
for i in argj:
simplif += i + " "
simplif = simplif[:-1]
ljinux.based.shell('argj = "' + simplif + '"', led = False) # provide arguments
ljinux.based.shell(
'argj = "' + simplif + '"', led=False
) # provide arguments
for commandd in lines:
ljinux.based.shell(commandd, led = False) # yes stonks
ljinux.based.shell(commandd, led=False) # yes stonks
f.close()
try:
del ljinux.based.user_vars["argj"]
except KeyError:
pass
except OSError:
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle
print("based: " + argj[0] + ": No such file or directory\n")

def helpp(dictt): # help
Expand Down Expand Up @@ -1376,7 +1378,9 @@ def iff(inpt): # the if, the pinnacle of ai WIP
print("based: Invalid action type: " + condition[i])
break
if val == 1:
ljinux.based.shell(" ".join(inpt[next_part:]), led = False)
ljinux.based.shell(
" ".join(inpt[next_part:]), led=False
)
del next_part
del val
except KeyError:
Expand Down Expand Up @@ -1664,23 +1668,23 @@ def shell(
term.focus = 0
stdout.write("\n")
elif term.buf[0] is 1:
ljinux.io.ledset(2) # keyact
ljinux.io.ledset(2) # keyact
print("^C")
term.buf[1] = ""
term.focus = 0
term.clear_line()
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle
elif term.buf[0] is 2:
ljinux.io.ledset(2) # keyact
ljinux.io.ledset(2) # keyact
print("^D")
global Exit
global Exit_code
Exit = True
Exit_code = 0
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle
break
elif term.buf[0] is 3: # tab key
ljinux.io.ledset(2) # keyact
ljinux.io.ledset(2) # keyact
tofind = term.buf[
1
] # made into var for speed reasons
Expand All @@ -1703,9 +1707,9 @@ def shell(
del bins
del tofind
del candidates
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle
elif term.buf[0] is 4: # up
ljinux.io.ledset(2) # keyact
ljinux.io.ledset(2) # keyact
try:
neww = ljinux.history.gett(
ljinux.history.nav[0] + 1
Expand All @@ -1721,9 +1725,9 @@ def shell(
except IndexError:
pass
term.clear_line()
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle
elif term.buf[0] is 7: # down
ljinux.io.ledset(2) # keyact
ljinux.io.ledset(2) # keyact
if ljinux.history.nav[0] > 0:
if ljinux.history.nav[0] > 1:
term.buf[1] = ljinux.history.gett(
Expand All @@ -1737,7 +1741,7 @@ def shell(
term.focus = ljinux.history.nav[1]
ljinux.history.nav[0] = 0
term.clear_line()
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle
ljinux.backrounding.main_tick()
try:
if command_input[:1] != " " and command_input != "":
Expand All @@ -1757,7 +1761,7 @@ def shell(
if not Exit:
res = ""
if led:
ljinux.io.ledset(3) # act
ljinux.io.ledset(3) # act
if not (command_input == ""):
gc.collect()
gc.collect()
Expand Down Expand Up @@ -1834,20 +1838,27 @@ def shell(
): # this is a pipe :)
ljinux.based.silent = True
the_pipe_pos = command_input.find("|", 0)
ljinux.based.shell(command_input[: the_pipe_pos - 1], led = False)
ljinux.based.shell(
command_input[: the_pipe_pos - 1], led=False
)
ljinux.based.silent = False
ljinux.based.shell(
command_input[the_pipe_pos + 2 :]
+ " "
+ ljinux.based.user_vars["return"], led = False
+ ljinux.based.user_vars["return"],
led=False,
)
del the_pipe_pos
elif ("&&" in command_input) and not (
"|" in command_input
): # this is a dirty pipe :)
the_pipe_pos = command_input.find("&&", 0)
ljinux.based.shell(command_input[: the_pipe_pos - 1], led = False)
ljinux.based.shell(command_input[the_pipe_pos + 2 :], led = False)
ljinux.based.shell(
command_input[: the_pipe_pos - 1], led=False
)
ljinux.based.shell(
command_input[the_pipe_pos + 2 :], led=False
)
del the_pipe_pos
elif ("&&" in command_input) and (
"|" in command_input
Expand All @@ -1864,14 +1875,18 @@ def shell(
+ ljinux.based.user_vars["return"]
)
else: # the first pipe is a &&
ljinux.based.shell(command_input[: the_pipe_pos_2 - 1], led = False)
ljinux.based.shell(command_input[the_pipe_pos_2 + 2 :], led = False)
ljinux.based.shell(
command_input[: the_pipe_pos_2 - 1], led=False
)
ljinux.based.shell(
command_input[the_pipe_pos_2 + 2 :], led=False
)
del the_pipe_pos_1
del the_pipe_pos_2
else:
pass
if led:
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle
gc.collect()
gc.collect()
return res
Expand All @@ -1897,7 +1912,7 @@ class farland: # wayland, but like a farfetched dream

def setup():
global display_availability
ljinux.io.ledset(3) # act
ljinux.io.ledset(3) # act
try:
i2c = busio.I2C(
pintab[configg["displaySCL"]], pintab[configg["displaySDA"]]
Expand All @@ -1919,7 +1934,7 @@ def setup():
except KeyError:
pass
dmtex("Unloaded display libraries")
ljinux.io.ledset(1) # idle
ljinux.io.ledset(1) # idle

def frame():
global display_availability
Expand Down
8 changes: 4 additions & 4 deletions neopixel_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ class neopixel_colors:
"""
Ljinux colors for the neopixel led
"""

idle = bytearray([3, 0, 0]) # for idling in terminal
idletype = bytearray([2, 0, 0]) # whilst chars are being inputted

activity = bytearray([5,5,0])
activity = bytearray([5, 5, 0])

waiting = bytearray([0, 0, 5]) # done with init, waiting for serial

error = bytearray([0, 50, 0])

killtheuser = bytearray([255, 255, 255]) # kekw
off = bytearray([0, 0, 0]) # power off the led

off = bytearray([0, 0, 0]) # power off the led
2 changes: 1 addition & 1 deletion rootfilesystem/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def jrub(texx=None): # basic logging for the launcher
print("\n\nLjinux crashed with:\t" + str(type(err))[8:-2] + ": " + str(err))
del err
Exit_code = 1
oss.io.ledset(0) # idle
oss.io.ledset(0) # idle

oss.farland.clear()
jrub("Cleared display")
Expand Down

0 comments on commit 0c4df4a

Please sign in to comment.