summaryrefslogtreecommitdiff
path: root/comp.py
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-12-18 23:14:40 -0300
committerJesusaves <cpntb1@ymail.com>2020-12-18 23:14:40 -0300
commit0933a22a34d26dbe64e20e84e4700807ba7be3a9 (patch)
tree9e61382c172da4b3bd0a69e470547db8df4ff233 /comp.py
downloadupdates-0933a22a34d26dbe64e20e84e4700807ba7be3a9.tar.gz
updates-0933a22a34d26dbe64e20e84e4700807ba7be3a9.tar.bz2
updates-0933a22a34d26dbe64e20e84e4700807ba7be3a9.tar.xz
updates-0933a22a34d26dbe64e20e84e4700807ba7be3a9.zip
Initial commit
Diffstat (limited to 'comp.py')
-rwxr-xr-xcomp.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/comp.py b/comp.py
new file mode 100755
index 0000000..97ec03a
--- /dev/null
+++ b/comp.py
@@ -0,0 +1,68 @@
+#!/usr/bin/python2.7
+########################################################################################
+# This file is part of Spheres.
+# Copyright (C) 2019 Jesusalva
+
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+########################################################################################
+# This builds live/ folder for Update Server
+import subprocess, json, sys, os, traceback
+PATH="/var/www/html/assets"
+
+# Delete previous deployment
+subprocess.call("rm --recursive %s/*" % PATH, shell=True)
+f=open("resources.json", "w")
+
+rc=[]
+
+# Go through every file in raw and give them a hash
+for path, subdir, files in os.walk("raw/"):
+ for n in files:
+ fn=os.path.join(path, n)
+
+ # Ignored files
+ if fn.endswith("~"):
+ continue
+
+ # Copy and update resource table
+ print(fn)
+ try:
+ NAME=fn.replace("raw/", "").replace("/", "_")
+ EXT=NAME.split(".")[-1:][0]
+ NAME=NAME.split(".")[:-1][0]
+ ## TODO code
+ if EXT in ["png", "jpg", "jpeg"]:
+ subprocess.call("convert %s %s/%s" % (fn, PATH, NAME), shell=True)
+ EXT="webp"
+ else:
+ subprocess.call("cp %s %s/%s.%s" % (fn, PATH, NAME, EXT), shell=True)
+ rc.append([NAME, EXT])
+ except:
+ traceback.print_exc()
+ pass
+
+# Save new summary
+json.dump(rc, f)
+f.close()
+
+# Create blank index page to disable dir listing
+subprocess.call("touch %s/index.html" % PATH, shell=True)
+
+# Correct permissions
+subprocess.call("chown -R www-data:www-data %s/*" % PATH, shell=True)
+subprocess.call("chmod --recursive o-rwx %s/*" % PATH, shell=True)
+
+# TODO: zip everything and provide an all-in-one download?
+