
| Current Path : /home/ift/52_procpy/dataninja/scripts/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //home/ift/52_procpy/dataninja/scripts/mk_inst.py |
# -*- coding: utf-8 -*-
import os
import re
import logging
setup = '''
from distutils.core import setup
setup (
name = "procpy",
version = "0.21",
author = "IfT",
author_email = "info@ift-informatik.de",
packages = [ "---SUBPACKAGES---" ],
scripts = [
'''
m1 = re.search(r"name +\= +\"(.*?)\"",setup)# procpy
m2 = re.search(r"version +\= +\"(.*?)\"",setup)# 0.21
dist = m1.group(1) + "-" + m2.group(1)# procpy-0.21
name = m1.group(1)# procpy
subpackages = { }
if not (dist == None):
os.system("rm -R " + dist)# deletes the old distribution with his content.
if not ((dist + ".zip") == None):
os.system("rm " + dist + ".zip")# deletes the old compressed distribution.
os.system("mkdir " + dist)# procpy-0.21
os.system("mkdir " + dist + "/" + name)# procpy-o.21/procpy
print 'dist = ', dist
print 'name = ', name
# some files and directories missed
'''
for file0 in [
"__init__.py",
"mysqlite.py",
"objpickle.py",
"xlsmanager.py",
"prcmanager.py",
"caller.py",
"multilingual.py",
"gui1.py",
"gui_file.py",
#"gparser.py",
"README_FIRST.txt",# exists no more
"scripts/oa",
"scripts/oa.bat",
"docs/procpy_userguide.md",
"examples/ex01_simple_general_example.gml",
"examples/ex02_more_paths_example.gml",
"examples/bpm7a.py",
"examples/bpm7a.graphml",
"examples/__init__.py",
]:
'''
for file0 in [
"__init__.py",
"arrow.py",
"block.py",
"caller.py",
"canvasvg.py",
"changesamples.py",
"config.py",
"examples/__init__.py",
"gui1.py",
"gui_file.py",
"loop_exit.py",
"loop_tk.py",
"MANIFEST.in",
"monitor.py",
"multilingual.py",
"mysqlite.py",
"objpickle.py",
"prcmanager.py",
"procobj.py",
"Readme.md",
"README.txt",
#"rearr_circle.py", <-- exists no more
"rearr_grid.py",
"rearr_sugiyama.py",
"remoteloops.py",
"scripts/__init__.py",# <-- empty
"scripts/adr",
"scripts/adr.bat",
"scripts/mk_inst.py",# <-- contains also a setup() method
"scripts/oa",
"scripts/oa.bat",
"scripts/oai",
"scripts/oai.bat",
"scripts/oap",
"scripts/oap.bat",
"scripts/procpy_caller",
"scripts/repeat.py",
"server/Readme.md",
"server/__init__.py",
"server/client.py",
"server/guiExample.py",
#"server/rpc_backend/__init__.py",
"server/server.py",
"setup.py",
"sync.bat",
"test/__init__.py",
"test/guitest.csv",
"test/guitest.db",
"test/guitest.py",
"test/python", #<-- empty
"test/test1.py",
"test/workflow.txt",
"test/x-guitest.csv",
"test/xxx.db",
"testapi.py",
"xlsmanager.py",
"xxx.db"
]:
m = re.search(r"^(.*?\/?)([^\/]+)$",file0)# In each file, extracts (begin)(begins with backslash or slash)
dir = m.group(1)# the name of the containing directory
file = m.group(2)# the name of the file
if dir == "":# propy/\<file>
if re.search(r"\.py$",file):# python module
if re.search(r"^(setup\.py)$",file):#setup.py
os.system("cp " + file + " "+dist)# procpy-0.21/setup.py
elif re.search(r"^(__init__\.py)$",file):# __init__.py
os.system("cp " + file + " "+dist+"/"+name)# procpy-0.21/procpy/__init__.py
#elif re.search("[aeoeueAEOEUEss]",open(file).read()):# <file>.py contains at least some ae, oe, ue, AE, OE, UE, or ss
#os.system("cp " + file + " "+dist+"/"+name)# procpy-0.21/procpy/<file>.py
elif re.search("(eval|exec)",open(file).read()):#<file>.py contains eval or exec
os.system("pyminifier " + file + " > " + dist+"/"+name+"/"+file)# compress <file>.py and push it in procpy-0.21/procpy/<file>.py
else:
os.system("pyminifier --obfuscate-variables " + file + " > " + dist+"/"+name+"/"+file)# compress <file>.py and variable names and push it in procpy-0.21/procpy/<file>.py
else:
os.system("cp " + file + " "+dist)#procpy-021/<file.ext>
else:#procpy/\<dir>.../\<file>
if not os.path.isdir(dist+"/"+dir):# not procpy-0.21/<dir>
os.system("mkdir " + dist+"/"+dir)# creates procpy-0.21/<dir>
if not os.path.isdir(dist+"/"+name+"/"+dir):# not procpy-0.21/procpy/<dir>
os.system("mkdir " + dist+"/"+name+"/"+dir)# creates procpy-0.21/procpy/<dir>
if dir == "scripts/":
setup = setup + " \"scripts/" + file + "\",\n"# scripts.append(scripts/<file>)
os.system("cp " + dir+file + " " + dist+"/"+dir)# procpy-0.21/<dir>/<dir><file>. A slash should be missed between dir and file.
elif re.search(r"\.py$",file):# python module
os.system("cp " + dir+file + " " + dist+"/"+name+"/"+dir)# procpy-0.21/procpy/<dir>/<dir><file>.py - A slash should be missed between dir and file.
subpackages[ "\", \"" + re.sub(r"\/","",dir,9999) ] = 1
else: # another module
os.system("cp " + dir+file + " " + dist+"/"+dir)# procpy-0.21/<dir>/<dir><file.ext>
os.system("rmdir " + dist+"/"+dir)# procpy-0.21/<dir>
os.system("rmdir " + dist+"/"+name+"/"+dir)# procpy-0.21/procpy/<dir>
print 'after the for'
setup = re.sub(r"---SUBPACKAGES---",name+",".join(subpackages.keys()),setup) + " ]\n)\n"
print setup
logging.basicConfig(filename='scripts/setup.py', level=logging.DEBUG, filemode='w', format='#[%(asctime)s] %(message)s')
logging.info(' generated by running \'python scripts/mk_inst.py\' in the terminal.\n'+setup)
if not(dist == None):
open(dist+"/setup.py","w").write(setup)
os.system("zip -r " + dist + ".zip " + dist)
os.system("rm -R " + dist)
os.system("scp " + dist + ".zip 85.214.125.106:/home/ift/ift-intern-tools/11_yed")