Add containerization and make this bad boy work on Windows and MacOS

This commit is contained in:
omer
2024-02-28 19:08:07 -06:00
parent d58a0543eb
commit df7a63e047
557 changed files with 6647 additions and 5493 deletions
+1 -6
View File
@@ -1,7 +1,2 @@
# hm_web
hearthmod web interface allows users to create account, sign in, modify decks, etc.
# This is not a standalone project!
[hm_web](https://github.com/farb3yonddriv3n/hm_web) is part of [hearthmod software stack](https://github.com/hearthmod/hearthmod)
hearthmod web server
Regular → Executable
+62 -49
View File
@@ -28,13 +28,12 @@ ERR_3 = 3
web.config.debug = False
urls = ('/', 'home',
urls = ('/', 'home',
'/signup', 'signup',
'/signin', 'signin',
'/mod/create', 'mod_create',
'/mod/edit/.*', 'mod_edit',
'/mod', 'mod',
'/deck/.*', 'deck_edit',
'/deck', 'deck',
'/faq', 'faq',
'/rss', 'rss',
'/ladder', 'ladder'
@@ -48,6 +47,10 @@ session = web.session.Session(app, store, initializer={'login': 0})
cb = Bucket('couchbase://localhost/hbs', password='aci')
chlog = ['gameclient', 'lobbyserver', 'gameserver', 'database', 'web']
############
def rand(num):
return ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(num)])
@@ -55,13 +58,6 @@ class faq:
def GET(self):
return render.base(session, render.faq(), [], [])
class mod_edit:
def GET(self):
s = web.ctx['path'].split("/")
m = s[len(s) - 1]
print m
return render.base(session, [], [], [])
class ladder:
def GET(self):
players = []
@@ -74,6 +70,25 @@ class ladder:
return render.base(session, render.ladder(players), [], [])
class rss:
def GET(self):
p = Popen("ls -la /proc/`ps aux| grep \"hm_gameserver\" | grep -v \"grep\" | awk '{print $2}'`/fd | wc -l", shell=True, stdout=PIPE)
out, err = p.communicate()
p = Popen("ls -la /proc/`ps aux| grep \"hm_lobbyserver\" | grep -v \"grep\" | awk '{print $2}'`/fd | wc -l", shell=True, stdout=PIPE)
out1, err1 = p.communicate()
return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\
<rss version=\"2.0\">\
<channel>\
<title>hearthmod</title>\
<item>\
<title>[g:%s] [l:%s]</title>\
</item>\
</channel>\
</rss>" % (out.rstrip('\n'), out1.rstrip('\n'))
class home:
def GET(self):
return render.base(session, render.home(), [], [])
@@ -83,36 +98,38 @@ class mod:
print 'mod init'
def POST(self):
#try:
d = json.loads(web.data())
if(len(d['name']) > 0 and len(d['url']) > 0):
mod = {'name': d['name'], 'url': d['url'], 'cards': []}
cb.upsert('u:mod_%s' % d['name'], mod)
print web.data()
'''
j = json.loads(web.data())
return 'success'
if(j == None):
return -1
return 'fail'
print j
if(len(j) == 1):
if 'modified' in j:
return self.modifiedCardTags(j['modified'])
elif 'card' in j:
return self.cardTags(j['card'], self.e)
elif 'remove' in j:
return self.enabledCardRemove(j['remove'])
elif 'publish' in j:
return self.modPublish(j['publish'])
#except:
# print 'except'
# return ''
else:
return self.storeLoaded(j)
'''
def GET(self):
if(session.login == 0):
return render.base(session, render.login_required(), [], [])
l = []
for result in View(cb, "dev_mods", "mods"):
l.append({ "url": result.value["url"], "name": result.value["name"] })
return render.base(session, render.mod(['Defense of the Ancients']), [], [])
return render.base(session, render.mod(l), [], [])
class mod_edit:
class mod_create:
def __init__(self):
self.e = xml.etree.ElementTree.parse('cache/c0').getroot()
self.cards = self.defaultSchema()
s = web.ctx['path'].split("/")
self.modname = "u:mod_%s" % s[len(s) - 1]
def defaultSchema(self):
f = open('cache/cards.basic')
@@ -175,8 +192,8 @@ class mod_edit:
def modPublish(self, modName):
try:
print 'publishing mod ' + self.modname
loaded = cb.get(self.modname).value
print 'publishing mod ' + modName
loaded = cb.get('u:mod_woa').value
names = []
f = open('cache/cards.basic')
@@ -202,7 +219,7 @@ class mod_edit:
enabledCards = self.modCards(new[0][1], atype.findall("Tag"), enabledCards)
break
f = open(self.modname[2:], "w")
f = open("customMod", "w")
f.write(enabledCards)
f.close()
@@ -216,7 +233,7 @@ class mod_edit:
p3 = f.read()
f.close()
f = open("xml_%s" % self.modname[2:], "w")
f = open("test", "w")
f.write(p1 + xmlstr[38:] + p3)
f.close()
@@ -228,13 +245,13 @@ class mod_edit:
def enabledCardRemove(self, j):
try:
loaded = cb.get(self.modname).value
loaded = cb.get('u:mod_woa').value
# delete if element exists
for l in loaded['cards']:
if l[0][1] == j:
loaded['cards'].remove(l)
break
cb.upsert(self.modname, loaded)
cb.upsert('u:mod_woa', loaded)
names = []
for l in loaded['cards']:
@@ -243,13 +260,13 @@ class mod_edit:
return json.dumps(names)
except:
cb.upsert(self.modname, {"cards": [j]})
cb.upsert('u:mod_woa', {"cards": [j]})
return ""
def getStored(self):
try:
x = cb.get(self.modname)
x = cb.get('u:mod_woa')
loaded = x.value
except:
return []
@@ -262,18 +279,18 @@ class mod_edit:
def storeLoaded(self, j):
try:
loaded = cb.get(self.modname).value
loaded = cb.get('u:mod_woa').value
# replace if element exists
for l in loaded['cards']:
if l[0][1] == j[0][1]:
loaded['cards'].remove(l)
break
loaded['cards'].append(j)
cb.upsert(selfmodname, loaded)
cb.upsert('u:mod_woa', loaded)
except:
cb.upsert(selfmodname, {"cards": [j]})
cb.upsert('u:mod_woa', {"cards": [j]})
loaded = cb.get(self.modname).value
loaded = cb.get('u:mod_woa').value
names = []
for l in loaded['cards']:
@@ -285,7 +302,7 @@ class mod_edit:
def modifiedCardTags(self, j):
#try:
loaded = cb.get(self.modname).value
loaded = cb.get('u:mod_woa').value
for l in loaded['cards']:
if l[0][1] == j:
names = []
@@ -335,7 +352,7 @@ class mod_edit:
result = self.modPublish(j['publish'])
if(result == "success"):
os.system("cd script && bash publish.sh")
os.system("sh test.sh")
return result
@@ -418,13 +435,9 @@ class signin:
return r
class deck:
def __init__(self):
s = web.ctx['path'].split("/")
self.modname = s[len(s) - 1]
def save_deck(self, arr):
out = cb.set('u:deck_%s_%s' % (self.modname, session.secret), arr)
out = cb.set('u:deck_%s' % session.secret, arr)
return ERR_0
@@ -434,7 +447,7 @@ class deck:
return render.base(session, render.login_required(), [], [])
cards = []
loaded = cb.get('u:mod_%s' % self.modname).value
loaded = cb.get('u:mod_woa').value
for l in loaded['cards']:
names = []
enabled = 0
@@ -459,7 +472,7 @@ class deck:
cards.append(names)
try:
loaded = cb.get('u:deck_%s_%s' % (self.modname, session.secret)).value
loaded = cb.get('u:deck_%s' % session.secret).value
except:
loaded = {}
@@ -0,0 +1,3 @@
KGRwMQpTJ2lwJwpwMgpWMTcyLjE4LjAuMQpwMwpzUydzZWNyZXQnCnA0ClZzR0lhSUoKcDUKc1Mn
dXNlcicKcDYKVnRlc3QKcDcKc1Mnc2Vzc2lvbl9pZCcKcDgKUyc1Njc1OWMxYjJlZTRkNmE5NDQw
MTE1MzQ1Y2ZkOWQyZDcwZGYwODJiJwpwOQpzUydsb2dpbicKcDEwCkkxCnMu
@@ -0,0 +1,3 @@
KGRwMQpTJ2lwJwpwMgpWMTkyLjE2OC4zMi4xCnAzCnNTJ2xvZ2luJwpwNApJMApzUyd1c2VyJwpw
NQpTJycKc1Mnc2Vzc2lvbl9pZCcKcDYKUyc3YTE0YjM4MTE0NDQ2ZTU2NzIyNzA5MDliNDQ5YWNm
N2I1NjYwZTg1JwpwNwpzLg==
@@ -0,0 +1,2 @@
KGRwMQpTJ2lwJwpwMgpWMTkyLjE2OC4xNi4xCnAzCnNTJ2xvZ2luJwpwNApJMApzUydzZXNzaW9u
X2lkJwpwNQpTJzhjOTY0ZGM4NjIzZGI2Y2RlODZmNWE1NjhmNjE1OTI2NWZmNDJiZTAnCnA2CnMu
@@ -0,0 +1,2 @@
KGRwMQpTJ2lwJwpwMgpWMTkyLjE2OC4xNi4xCnAzCnNTJ2xvZ2luJwpwNApJMApzUydzZXNzaW9u
X2lkJwpwNQpTJzk0NDRmM2FiMWVhZDY0OTk1MWU5NjNhYWU4ZDg2NTJlNzQ4M2M5ZjgnCnA2CnMu
@@ -0,0 +1,2 @@
KGRwMQpTJ2lwJwpwMgpWMTkyLjE2OC40OC4xCnAzCnNTJ2xvZ2luJwpwNApJMApzUydzZXNzaW9u
X2lkJwpwNQpTJzlhYjc5YTdjNzBiZjg5OTdjN2E1Y2VhZGU2ZmU5OGYzYTlhZDA5Y2QnCnA2CnMu
@@ -0,0 +1,2 @@
KGRwMQpTJ2lwJwpwMgpWMTcyLjE4LjAuMQpwMwpzUydsb2dpbicKcDQKSTAKc1Mnc2Vzc2lvbl9p
ZCcKcDUKUydhYWNjMWMyNjBmNTBiYmFmMDBhZTI4MjU4NTkxYTk4MDBjMzFiMTM4JwpwNgpzLg==
@@ -0,0 +1,2 @@
KGRwMQpTJ2lwJwpwMgpOc1MnbG9naW4nCnAzCkkwCnNTJ3Nlc3Npb25faWQnCnA0ClMnYjVlYmE5
ZjY1Y2IzM2RjZDBhN2RiYjlhYjQxZjYzMDVkMmQ3NjQyZicKcDUKcy4=
Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Some files were not shown because too many files have changed in this diff Show More