Compare commits
2 commits
649f1c8ff7
...
418c89d375
Author | SHA1 | Date | |
---|---|---|---|
Izalia Mae | 418c89d375 | ||
Izalia Mae | 78b0c55baa |
66
dirsize.py
Normal file
66
dirsize.py
Normal file
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env python3
|
||||
import argparse, sys
|
||||
from pathlib import Path
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('path', help='Path to recursively search')
|
||||
parser.add_argument('--progress', '-p', action='store_true', help='Enables displaying the current size in progress')
|
||||
parser.add_argument('--count', '-c', default=100, type=int, help='The number of files to go through before updating the status (--progress implied)')
|
||||
args = parser.parse_args()
|
||||
path = Path(args.path)
|
||||
|
||||
|
||||
if args.path.startswith('~'):
|
||||
path = path.expanduser()
|
||||
|
||||
size = 0
|
||||
files = 0
|
||||
filenum = 0
|
||||
chunk = 0
|
||||
|
||||
def print_size():
|
||||
size_mib = round(size/1024/1024, 2)
|
||||
sys.stdout.write(f'Current size: {size_mib}MiB\r')
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def main():
|
||||
global size
|
||||
global files
|
||||
global filenum
|
||||
global chunk
|
||||
|
||||
if not path.exists():
|
||||
print('Path doen\'t exist:', str(path))
|
||||
return
|
||||
|
||||
if not path.is_dir():
|
||||
print('Path is not a dir:', str(path))
|
||||
return
|
||||
|
||||
for f in path.glob('**/*'):
|
||||
if f.is_file():
|
||||
size += f.stat().st_size
|
||||
filenum += 1
|
||||
files += 1
|
||||
|
||||
if (args.progress or args.count != 100) and filenum >= args.count:
|
||||
chunk += 1
|
||||
filenum = 0
|
||||
print_size()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
try:
|
||||
ret = main()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
if args.progress or args.count != 100:
|
||||
print('\n')
|
||||
|
||||
if ret:
|
||||
print(f'Files: {files}')
|
||||
print(f'Size: {round(size/1024/1024, 2)} MiB')
|
|
@ -25,14 +25,20 @@ if len(sys.argv) < 2 or 'help' in sys.argv:
|
|||
|
||||
|
||||
host = sys.argv[1]
|
||||
token = Path('emoji_token.txt') #Gonna probably change this tbh
|
||||
failed = []
|
||||
options = {
|
||||
'api_base_url': 'https://'+host
|
||||
}
|
||||
|
||||
if token.is_file():
|
||||
options['access_token'] = token.open().read().replace('\n', '')
|
||||
try:
|
||||
tokens = json.load('emoji_tokens.json')
|
||||
except:
|
||||
tokens = {}
|
||||
|
||||
token = tokens.get(host)
|
||||
|
||||
if token:
|
||||
options['access_token'] = token
|
||||
|
||||
mastodon = Mastodon(**options)
|
||||
|
||||
|
@ -41,13 +47,13 @@ if len(sys.argv) < 3:
|
|||
basepath = Path.cwd()
|
||||
|
||||
else:
|
||||
basepath = sys.argv[2]
|
||||
patharg = sys.argv[2]
|
||||
|
||||
if patharg.startswith('~'):
|
||||
basepath = Path.expanduser(patharg)
|
||||
|
||||
elif patharg.startswith('/'):
|
||||
basepath = Path(arg)
|
||||
basepath = Path(patharg)
|
||||
|
||||
else:
|
||||
basepath = Path.cwd().joinpath(patharg)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# Requires python-xlib (pip3 install xlib)
|
||||
#
|
||||
# Probably gonna rework the whole thing since there's a lot of
|
||||
# unnecessary code and then use the pulseaudio module
|
||||
# unnecessary code
|
||||
#
|
||||
|
||||
from Xlib.display import Display
|
||||
|
@ -92,4 +92,4 @@ class Listener:
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
Listener().run()
|
||||
Listener().run()
|
||||
|
|
78
proton-ge-updater.py
Normal file
78
proton-ge-updater.py
Normal file
|
@ -0,0 +1,78 @@
|
|||
#!/usr/bin/env python3
|
||||
import json, sys, tarfile, os
|
||||
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlparse
|
||||
from urllib.request import Request, urlopen, urlretrieve
|
||||
|
||||
|
||||
url = 'https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases/latest'
|
||||
protondir = Path('~/.steam/compatibilitytools.d/').expanduser()
|
||||
|
||||
|
||||
if not protondir.exists():
|
||||
protondir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
def dl_progress(count, bsize, size):
|
||||
progress = count * bsize / size
|
||||
term_width = os.get_terminal_size().columns
|
||||
status = ""
|
||||
|
||||
if progress >= 1:
|
||||
progress = 1
|
||||
status = "Done...\r\n"
|
||||
|
||||
text1 = f'\rDownloading {filename}: ['
|
||||
text2 = f'] {int(round(progress, 2)*100)}% {status}'
|
||||
|
||||
bar_length = term_width - len(text1 + text2)
|
||||
block = int(round(bar_length*progress))
|
||||
bar_progress = '#'*block + '-'*(bar_length - block)
|
||||
|
||||
sys.stdout.write(text1 + bar_progress + text2)
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def dl_progress_old(count, bsize, size):
|
||||
progress = count * bsize
|
||||
percent = progress / size
|
||||
|
||||
print(percent)
|
||||
|
||||
|
||||
with urlopen(Request(url, headers={'Accept': 'application/vnd.github.v3+json'})) as resp:
|
||||
data = json.loads(resp.read())
|
||||
|
||||
try:
|
||||
build = data['assets'][0]
|
||||
release = {
|
||||
'name': data['name'],
|
||||
'size': build['size'],
|
||||
'date:': build['created_at'],
|
||||
'url': build['browser_download_url']
|
||||
}
|
||||
|
||||
except KeyError as e:
|
||||
print('Failed to get build info:', e)
|
||||
sys.exit()
|
||||
|
||||
|
||||
filename = Path(urlparse(release['url']).path).name
|
||||
tarname = Path(f'/tmp/{filename}')
|
||||
extpath = protondir.joinpath(filename.replace('.tar.gz', ''))
|
||||
|
||||
|
||||
if not tarname.exists() and not extpath.exists():
|
||||
urlretrieve(release['url'], tarname, dl_progress)
|
||||
|
||||
|
||||
if not extpath.exists():
|
||||
print(f'Extracting {filename} to {extpath}')
|
||||
tar = tarfile.open(tarname)
|
||||
tar.extractall(protondir)
|
||||
print('Installed latest version of proton-ge')
|
||||
|
||||
else:
|
||||
print('Latest version of proton-ge already installed')
|
Loading…
Reference in a new issue