Last active
August 8, 2018 03:31
-
-
Save kayaked/7e74b8719b2e958425b83d4b81034ea6 to your computer and use it in GitHub Desktop.
trash. but it does actually work using anemone!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
import math | |
# This program is severely outdated. | |
# The updated version can be found at github.com/oganessium/pyrespringcreatorGUI | |
"""begin the spaghetti""" | |
if os.name != 'nt': | |
print("Error: This program is made for windows systems and is not yet compatible/tested with Unix systems.") | |
os.system("pause") | |
exit() | |
from tkinter import Tk | |
from tkinter.filedialog import askopenfilename | |
try: | |
subprocess.check_output(['ubuntu', 'run', 'mkdir', '~/Theme']) | |
except FileNotFoundError: | |
print("Error: Ubuntu is not present on this machine. Please install it from the Windows Store") | |
os.system("pause") | |
exit() | |
except Exception: | |
pass | |
print(" Jack's") | |
print(" RESPRING LOGO CREATOR") | |
print(" v0.0.1") | |
print("--------------------------------------\n") | |
print("Please input Path to image file: ") | |
Tk().withdraw() | |
filename = askopenfilename() | |
print(filename) | |
pkg = input("Input Package bundle name (ex. 'com.myname.mycreativelogoname'): ") | |
name = input("Input theme name: ") | |
ver = input("Input version (ex. 0.1): ") | |
desc = input("Input description of the logo: ") | |
authn = input("Input your name: ") | |
email = input("Input a valid e-mail: ") | |
option = input("Auto-Resize Image? (Y/N) (default N): ") | |
def modImage(): | |
try: | |
from PIL import Image | |
imageFile = filename | |
im1 = Image.open(imageFile) | |
owidth, oheight = im1.size | |
width=500 | |
height=math.floor((width*oheight)/owidth) | |
im = im1.resize((width, height), Image.BICUBIC) | |
ext = ".png" | |
im.save("img" + ext) | |
except ModuleNotFoundError: | |
print("Error: PIL not found. Run: py -m pip install Pillow") | |
exit() | |
if option == "Y": | |
modImage() | |
os.system("ubuntu run mkdir ~/Theme/src") | |
os.system("ubuntu run mkdir ~/Theme/dist") | |
os.system("ubuntu run mkdir ~/Theme/src/DEBIAN") | |
username = os.path.expanduser("~").rsplit("\\", 1)[1] | |
control = open("control", 'w+') | |
control.write("Package: {}\n".format(pkg.replace(" ", ""))) | |
control.write("Name: {}\n".format(name)) | |
control.write("Version: {}\n".format(ver)) | |
control.write("Architecture: iphoneos-arm\n") | |
control.write("Description: {}\n".format(desc)) | |
control.write("Maintainer: {} <{}>\n".format(authn, email)) | |
control.write("Author: {} <{}>\n".format(authn, email)) | |
control.write("Section: Themes\n") | |
control.write("Depends: com.anemonetheming.anemone\n") | |
control.close() | |
path = os.path.realpath(__file__).replace("\\", "/") | |
path=path.replace("C:","") | |
path=path.replace(" ", "\\ ") | |
path=path.rsplit("/", 1)[0] | |
name=name.replace(" ", "\ ") | |
os.system("ubuntu run mv /mnt/c{}/control ~/Theme/src/DEBIAN/".format(path)) | |
os.system("ubuntu run mkdir ~/Theme/src/Library") | |
os.system("ubuntu run mkdir ~/Theme/src/Library/Themes") | |
os.system("ubuntu run mkdir ~/Theme/src/Library/Themes/{}.theme".format(name)) | |
os.system("ubuntu run mkdir ~/Theme/src/Library/Themes/{}.theme/Bundles".format(name)) | |
os.system("ubuntu run mkdir ~/Theme/src/Library/Themes/{}.theme/Bundles/com.apple.ProgressUI".format(name)) | |
fg=name | |
os.system("ubuntu run cp /mnt/c{}/img.png ~/Theme/src/Library/Themes/{}.theme/Bundles/com.apple.ProgressUI/apple-logo@2x~ipad.png".format(path, name)) | |
os.system("ubuntu run cp /mnt/c{}/img.png ~/Theme/src/Library/Themes/{}.theme/Bundles/com.apple.ProgressUI/apple-logo@3x~iphone.png".format(path, name)) | |
os.system("ubuntu run cp /mnt/c{}/img.png ~/Theme/src/Library/Themes/{}.theme/Bundles/com.apple.ProgressUI/apple-logo-black@2x~ipad.png".format(path, name)) | |
os.system("ubuntu run cp /mnt/c{}/img.png ~/Theme/src/Library/Themes/{}.theme/Bundles/com.apple.ProgressUI/apple-logo@2x~iphone.png".format(path, name)) | |
os.system("ubuntu run cp /mnt/c{}/img.png ~/Theme/src/Library/Themes/{}.theme/Bundles/com.apple.ProgressUI/apple-logo-black@2x~iphone.png".format(path, name)) | |
os.system("ubuntu run cp /mnt/c{}/img.png ~/Theme/src/Library/Themes/{}.theme/Bundles/com.apple.ProgressUI/apple-logo-black@3x~iphone.png".format(path, name)) | |
info = open("Info.plist", "w+") | |
info.write('<?xml version="1.0" encoding="UTF-8"?>\n') | |
info.write('<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n') | |
info.write('<plist version="1.0">\n') | |
info.write('<dict>\n') | |
info.write('\t<key>PackageName</key>\n') | |
info.write('\t<string>{}</string>\n'.format(name)) | |
info.write('</dict>\n</plist>') | |
info.close() | |
os.system("ubuntu run mv /mnt/c{}/Info.plist ~/Theme/src/Library/Themes/{}.theme/Bundles/".format(path, fg)) | |
os.system("ubuntu run chmod -R 0755 ~/Theme/src/DEBIAN") | |
os.system("ubuntu run dpkg-deb -b -Zgzip ~/Theme/src ~/Theme/dist") | |
os.system("ubuntu run mv ~/Theme/dist/{}_{}_iphoneos-arm.deb /mnt/c{}/".format(pkg, ver, path)) | |
os.system("ubuntu run rm -r ~/Theme/src") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites:
This should work fine if you have these