Skip to content

Commit

Permalink
Better installer for non Debian based Unix systems
Browse files Browse the repository at this point in the history
  • Loading branch information
Haz_01 committed Apr 28, 2020
1 parent 1d207b5 commit 9fa78e9
Show file tree
Hide file tree
Showing 48 changed files with 1,728 additions and 6 deletions.
21 changes: 15 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
#!/bin/sh
{
echo "[0/5] - Concatinating python source"
echo "[0/7] - Concatinating python source"
cat src/menu.py src/config.py src/tclock.py > src/main.py
echo "[1/5] - Copying python source"
echo "[1/7] - Copying python source"
cp -r src/* tclock-deb/usr/share/tclock/
echo "[2/5] - deleting debug flag"
cp -r src/* install/usr/share/tclock/
echo "[2/7] - deleting debug flag"
rm tclock-deb/usr/share/tclock/debug
echo "[3/5] - making python executable"
rm install/usr/share/tclock/debug
echo "[3/7] - making python executable"
chmod 777 tclock-deb/usr/share/tclock/main.py
echo "[4/5] - Packaging For Debian"
chmod 777 install/usr/share/tclock/main.py
echo "[4/7] - Packaging For Debian"
dpkg --build tclock-deb
echo "[5/5] - Done"

echo "[5/7] - Compressing Install.zip"
zip -r9 build/tclock.zip ./install/
echo "[6/7] - Copying last files to build folder"
mv tclock-deb.deb build/tclock.deb
cp LICENSE build/LICENSE
echo "[7/7] - Done"
}||{
echo "Failed"
}
21 changes: 21 additions & 0 deletions build/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Haz001

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file added build/tclock.deb
Binary file not shown.
Binary file added build/tclock.zip
Binary file not shown.
8 changes: 8 additions & 0 deletions install/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
{
echo "[0/1] Copying files to computer"
cp -r ./usr/ /
echo "[1/1] Install Complete"
}||{
echo "Failed, please make sure you run `install.sh` with super user privliges"
}
1 change: 1 addition & 0 deletions install/usr/bin/tclock
21 changes: 21 additions & 0 deletions install/usr/share/tclock/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Haz001

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
182 changes: 182 additions & 0 deletions install/usr/share/tclock/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# ____ ___ _ _ _____ ___ ____
# / ___/ _ \| \ | | ___|_ _/ ___| _ __ _ _
# | | | | | | \| | |_ | | | _ | '_ \| | | |
# | |__| |_| | |\ | _| | | |_| |_| |_) | |_| |
# \____\___/|_| \_|_| |___\____(_) .__/ \__, |
# |_| |___/
# Config Class
# MIT License
# Copyright (c) 2020 Haz001

from pathlib import Path
import os
class config:

home = str(Path.home())
def __init__(self, cf, reado=True):

self.path = self.home+"/.config/tclock/"+cf+".conf"
self.reado = reado
self.sr = self.stream(self.path,reado)

def get(self, name):
f = self.sr.read(name)

if(f == None):
return None
else:
if (f[0] == None):
return None
else:
return f[0]
def type(self, name):
f = self.sr.read(name)
if (len(f)<2):
return None
else:
return f[1]
def set(self, name, value):
if(self.reado):
pass
else:
self.sr.write(str(name),str(value))
def praw(self):
f = open(self.path,'r')
txt = f.read()
return str(self.sr.uncomp())
class stream:
def __init__(self,cpath,readonly):
y = Path(cpath)

if(y.exists()):
self.cpath = cpath
self.reado = readonly
x = open(cpath,'r')
self.data = x.read()
x.close()
else:
z = cpath.split("/")

for i in range(len(z)+1):

a = "/".join(z[:(i)])
if(i == len(z)):
if(not Path(a).is_file()):

open(a,'w').close()
else:
if( not Path(a).is_dir()):

os.mkdir(a)


self.cpath = cpath
self.reado = readonly
x = open(cpath)
self.data = x.read()
x.close()


def uncomp(self):
data = self.data
result = ""
part = 0 ## 0 - name,1 - value, 2 - type
count = 0
quotes = False
name = {}
tname = ""
value = {}
tvalue = ""
t = {}
tt = ""
lstchr = ""
for i in range(len(data)):
cchar = data[i]
if(quotes):
if((cchar=="\"")and not(lstchr == "\\")):
quotes = False
else:
if (part == 0):
tname += data[i]
elif (part == 1):
tvalue += data[i]
elif (part == 2):
tt += data[i]
else:
if((cchar=="\n")or(cchar=="\r")):
part = 0
name[count] = tname
tname = ""
value[count] = tvalue
tvalue = ""
if((tt == "")or(tt == None)):
tt = "s"
t[count] = tt
tt = ""
count += 1
elif((cchar==":")):
part += 1
elif(cchar=="\""):
quotes = True
lstchr = cchar
result = (name, value, t)
dic = {}
for i in range(count):
if((name[i] != None)and(name[i] != None)):
if(t[i] == ""):
dic[name[i]] = [value[i]]
else:
dic[name[i]] = [value[i],t[i]]
result = dic
return result
def read(self,name):
x = self.uncomp()
result = ""
if(name in x):
result = x[name]
else:
result = None
return result
def write(self,name,value):
dic = self.uncomp()
result = ""
if(name in dic): ## This might be used later, don't optimize yet.
dic[name] = value
else:
dic[name] = value
x = [ [k,v] for k, v in dic.items() ] ## convets dictionary to list
lname = []
lvalue = []
for i in range(len(x)):
lname.append(x[i][0])
lvalue.append(x[i][1])

txt = ""
for i in range(len(lname)):
if not((lname[i] == "")and(lvalue[i] == "")):
txt+=str("\""+str(lname[i])+"\":\""+str(lvalue[i])+"\"\n")
self.data = txt
f = open(self.cpath,'w')
f.write(txt)
f.close()
# NOTE: Simple test to see if it can write and read values
def test(self = None):
x = config("testfile",False)
import random
try:
y = str(random.randint(0,65535))
x.set("testvalue",str(y))
z = x.get("testvalue")
if(z == y):
pass
else:
print("Error with Config.py\nInit Test Failed.\nExpecting '"+y+"' as '"+str(type(y))+"' but got '"+z+"' as '"+str(type(z))+"'")
exit()
except OSError as e:
print("OS error: "+str(e))
exit()
finally:
del x
del y
del z
test()
21 changes: 21 additions & 0 deletions install/usr/share/tclock/data/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Haz001

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 12 additions & 0 deletions install/usr/share/tclock/data/github
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
_______ _____ _ _
|__ __/ ____| | | |
| | | | | | ___ ___| | __
| | | | | |/ _ \ / __| |/ /
| | | |____| | (_) | (__| <
|_| \_____|_|\___/ \___|_|\_\
The Terminal Clock
MIT License
Copyright (c) 2019 Haz001

Github:
https://github.com/Haz001/TClock
21 changes: 21 additions & 0 deletions install/usr/share/tclock/data/help
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
_______ _____ _ _
|__ __/ ____| | | |
| | | | | | ___ ___| | __
| | | | | |/ _ \ / __| |/ /
| | | |____| | (_) | (__| <
|_| \_____|_|\___/ \___|_|\_\
The Terminal Clock
MIT License
Copyright (c) 2019 Haz001

Usage: tclock [OPTION] [FILE, DATE]...

no optin Default settings
-m CLI Menu
-G GitHub Link

In Development
-i One Instance (good for 'watch' command or just to check time) [InDevelopment]
-w [FILE] Write out to file [InDevelopment]
-c [DATE] Count Down to that date [InDevelopment]
-g Graphical Mode [InDevelopment]
7 changes: 7 additions & 0 deletions install/usr/share/tclock/data/num/0
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
011111
1000001
1000001
1000001
1000001
1000001
011111
7 changes: 7 additions & 0 deletions install/usr/share/tclock/data/num/1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
0001
0011
0101
0001
0001
0001
1111111
7 changes: 7 additions & 0 deletions install/usr/share/tclock/data/num/2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1111111
0000001
0000001
1111111
1
1
1111111
7 changes: 7 additions & 0 deletions install/usr/share/tclock/data/num/3
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
111111
0000001
0000001
011111
0000001
0000001
111111
7 changes: 7 additions & 0 deletions install/usr/share/tclock/data/num/4
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
0000011
0000101
0001001
0010001
01111111
0000001
0000001
7 changes: 7 additions & 0 deletions install/usr/share/tclock/data/num/5
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1111111
1
1
111111
0000001
0000001
111111
7 changes: 7 additions & 0 deletions install/usr/share/tclock/data/num/6
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
011111
1000001
1
111111
1000001
1000001
011111
7 changes: 7 additions & 0 deletions install/usr/share/tclock/data/num/7
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1111111
0000001
000001
00001
0001
001
01
7 changes: 7 additions & 0 deletions install/usr/share/tclock/data/num/8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
011111
1000001
1000001
011111
1000001
1000001
011111
Loading

0 comments on commit 9fa78e9

Please sign in to comment.