Advertisement
austinh115

xat latest client to git

Aug 16th, 2017
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.84 KB | None | 0 0
  1. """
  2. Requires parallel, jpexs, and uncrustify
  3. For use on Linux, but I'm sure you can convert it
  4.  
  5. Could probably be optimized quite a bit, it was done relatively quick
  6. """
  7.  
  8. import subprocess
  9. from urllib.request import urlretrieve
  10. import sys
  11. import fileinput
  12. import glob
  13. import string
  14. import os
  15. import re
  16. import json
  17. import pprint
  18. import traceback
  19.  
  20. def getLatest():
  21.     try:
  22.         print("Getting latest chat version from chat.swf...",)
  23.         urlretrieve("http://xatech.com/web_gear/chat/chat2.swf", "chat.swf")
  24.         chat = subprocess.check_output("swfdump -a chat.swf | grep chat", shell=True).decode('utf-8')
  25.         subprocess.call("ls | grep -v latest.py | grep -v uncrustify.cfg | parallel rm -rf", shell=True)
  26.         chat = re.search("//www.xatech.com/web_gear/flash/(.*).swf", chat).group(1)
  27.         print("Got", chat)
  28.         return chat
  29.     except Exception as e:
  30.         print("Download failed 1")
  31.         print(e)
  32.         traceback.print_exc()
  33.         sys.exit(0)
  34.  
  35.  
  36. def download(chat):
  37.     print("Downloading http://www.xatech.com/web_gear/flash/" + chat.lower() + ".swf")
  38.     try:
  39.         urlretrieve("http://www.xatech.com/web_gear/flash/" +
  40.                     chat.lower() + ".swf", chat.lower() + ".swf")
  41.         print("Download successful")
  42.         return chat.lower() + ".swf"
  43.     except Exception as e:
  44.         print("Download failed 2")
  45.         print(e)
  46.         traceback.print_exc()
  47.         sys.exit()
  48.  
  49. def decompile(chat):
  50.     print("Decompiling ./" + chat.lower() + ".swf")
  51.     subprocess.call("ffdec -export fla \"./\" ./" + chat + ".swf", shell=True)
  52.     print('Decompiled')
  53.     return
  54.  
  55. def beautify():
  56.     subprocess.call('find . -name "*.as" | parallel uncrustify -c uncrustify.cfg --replace --no-backup', shell=True)
  57.     print("Done beautifying")
  58.     return
  59.  
  60. chat = getLatest()
  61.  
  62. download(chat)
  63. decompile(chat)
  64.  
  65. beautify()
  66.  
  67. subprocess.call("find . -name '*.swf' | gawk -F. '{print $2}' | gawk -F/ '{print $2}' | xargs git commit -am", shell=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement