代码拉取完成,页面将自动刷新
同步操作将从 LibQQt应用程序开发组织/Multi-environ Technology(PyMake) 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
"""PyMake 2.0.
Usage:
pymake2.py source [ --add | --del | --switch ] [ <config-file-name> ]
pymake2.py source --mod <config-file-name> <new-config-file-name>
pymake2.py source [ --show | --restore ]
pymake2.py list [ --vars | --pathes | --commands | --task ]
pymake2.py set ( env-var | env-path | cmd ) ( --add | --del | --mod ) <name> [ <value> ]
pymake2.py stream (--add | --del | --mod ) <name> [ <values> ... ]
pymake2.py exec <stream-names> ...
pymake2.py (-h | --help)
pymake2.py --version
Command:
source switch to another source file
set env-path config work directory
set env-var
set exec-dir config execute directory
list list configed values
Options:
-h --help Show this screen.
--version Show version.
--add
--del
--mod add or delete or modify a config or path
--switch switch to another source
--vars
--pathes
--commands
--task list info params
--show display haved task config files
--restore reset to pymake.json task config file
"""
# -*- coding: utf-8 -*-
import os
import re
import sys
import pwd
import shutil
import time
import json
import locale
import codecs
import threading
import subprocess
import collections
from pycore.pycore import *
from pycore.docopt import docopt
def main_function():
d = {
"add-path-to-env": {
"cmake-bin-path": "/Users/abel/Develop/b0-toolskits/compliers/CMake.app/Contents/bin",
"macosx-sdk-xcode": "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks",
"make-and-toolchain-path": "/usr/bin",
"qt5.9-clang64": "/Users/abel/Develop/b0-toolskits/Libraries/QtLibraries/5.9.1/clang_64/bin"
},
"env-variables": {
"PYCMD_MYNAME": "T.D.R"
},
"store-named-command": {
"mk-buildpath": "mkdir -p /Users/abel/Develop/c0-buildstation/mac-qqt",
"cd-buildpath": "cd /Users/abel/Develop/c0-buildstation/mac-qqt",
"cd-productpath": "cd /Users/abel/Develop/b1-Product/a0-qqtbased/Application",
"gen": "cmake -G\"Unix Makefiles\" -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}../../b1-Product/a0-qqtbased/Application ../../a0-Developworkspace/a0-qqtpruduct-qqtfoundation/",
"gen-xcode": "cmake -GXCode -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}../../b1-Product/a0-qqtbased/Application ../../a0-Developworkspace/a0-qqtpruduct-qqtfoundation/",
"install": "make install",
"make": "make -j4",
"msg": "echo 'work completed!'",
"pwd": "pwd",
"rmcache": "rm -f CMakeCache.txt"
},
"execute-stream": {
"buildqqt": [
"mk-buildpath",
"cd-buildpath",
"rmcache",
"gen",
"make",
"install",
"msg"
],
"genqqt": [
"mk-buildpath",
"cd-buildpath",
"gen",
"msg"
],
"packageqqt": [
"cd-productpath",
"pwd"
]
}
}
# python's transfer parameters is a unordered dict,
# these data will be unordered, you should copy them into pymake.json
if (not os.path.exists('pymake.json')):
writeJsonData('pymake.json', d)
"""
[pymake]
config = pymake.json
"""
file = 'pymake.json'
conf = MyConfigParser()
conf.read('pymake.ini')
if(conf.has_section('pymake') ):
if(conf.has_option('pymake', 'config')):
if(conf.get('pymake', 'config')):
file = conf.get('pymake', 'config')
print("use source config: %s" % file)
else:
conf.set('pymake', 'config', 'pymake.json')
conf.write(open('pymake.ini', 'w'))
print('initial pymake.ini')
else:
conf.set('pymake', 'config', 'pymake.json')
conf.write(open('pymake.ini', 'w'))
print('initial pymake.ini')
else:
conf.add_section('pymake')
conf.set('pymake', 'config', 'pymake.json')
conf.write(open('pymake.ini', 'w'))
print ( 'initial pymake.ini')
args = docopt(__doc__, version='pymake2.py v2.0')
#print(args)
exceptFile = ( 'pymake.ini', 'pymake.py', '.gitignore', '.git', 'pycore', 'README.md', '.idea')
while (True):
if(args['source'] is True):
if(args['--del'] is True):
if (args['<config-file-name>'] is not None and args['<config-file-name>'] == 'pymake.json'):
print('You can\'t remove pymake\'s file...')
elif (args['<config-file-name>'] is not None and not exceptFile.__contains__(args['<config-file-name>']) ):
os.remove(args['<config-file-name>'])
conf.set('pymake', 'config', 'pymake.json')
conf.write(open('pymake.ini', 'w'))
else:
print ( 'You can\'t remove pymake\'s file...')
elif(args['--add'] is True):
if (args['<config-file-name>'] is not None and not exceptFile.__contains__(args['<config-file-name>']) ):
if(file != args['<config-file-name>']):
shutil.copyfile(file, args['<config-file-name>'])
conf.set('pymake', 'config', args['<config-file-name>'])
conf.write(open('pymake.ini', 'w'))
else:
print('You can\'t add same named file...')
else:
print ( 'You can\'t add pymake\'s file...')
elif (args['--mod'] is True):
if ( ( args['<config-file-name>'] and args[
'<new-config-file-name>']) is not None and not \
exceptFile.__contains__(
args['<config-file-name>'])):
os.rename(args['<config-file-name>'],
args['<new-config-file-name>'])
if (file == args['<config-file-name>']):
conf.set('pymake', 'config',
args['<new-config-file-name>'])
conf.write(open('pymake.ini', 'w'))
else:
print ('You can\'t mod pymake\'s file...')
elif(args['--show'] is True):
files = os.listdir(os.getcwd())
for f in files:
if (not exceptFile.__contains__(f)):
print(f)
elif(args['--restore'] is True):
conf.set('pymake', 'config', 'pymake.json')
conf.write(open('pymake.ini', 'w'))
elif (args['--switch'] is True
or ( args['<config-file-name>'] is not None and args[\
'<config-file-name>'] != '' )):
if (args['<config-file-name>'] is not None and not exceptFile.__contains__(args['<config-file-name>']) ):
if (os.path.exists(args['<config-file-name>'])):
conf.set('pymake', 'config', args['<config-file-name>'])
conf.write(open('pymake.ini', 'w'))
print("switch to source config: %s" % args[
'<config-file-name>'])
else:
print("source file %s isn't exists" % args[
'<config-file-name>'])
else:
print('You can\'t switch pymake\'s file...')
else:
print(file)
return
else:
''
break
config = readJsonData(file)
#print(config)
while (True):
if (args['list'] == True):
if( args['--vars'] == True):
dict0 = config['env-variables'].copy()
for (k, v) in dict0.items():
print("%-24s %s" % (k, v) )
elif( args['--pathes'] == True):
dict0 = config['add-path-to-env'].copy()
for (k, v) in dict0.items():
print("%-24s %s" % (k, v) )
elif( args['--commands'] == True):
dict0 = config['store-named-command'].copy()
for (k, v) in dict0.items():
print("%-24s %s" % (k, v) )
elif( args['--task'] == True):
dict0 = config['execute-stream'].copy()
for (k,v) in dict0.items():
print("%-24s %s" % (k,v) )
else:
''
break
while (True):
if (args['set'] == True):
if (args['env-var'] is True):
if (args['--add'] == True):
if (args['<name>'] and args["<value>"] is not None):
config["env-variables"][args['<name>']] = args[
"<value>"]
print ( "successed %s:%s" % (args['<name>'],
args[ "<value>"]))
else:
''
elif (args['--del'] == True):
if (args["<name>"] is not None):
if (config['env-variables'].__contains__(
args['<name>'])):
config["env-variables"].__delitem__(
args['<name>'])
print ("successed %s" % (args['<name>']))
else:
''
else:
''
elif (args['--mod'] == True):
if (args['<name>'] and args["<value>"] is not None):
if (config['env-variables'].__contains__(
args['<name>'])):
config["env-variables"][args['<name>']] = \
args["<value>"]
print ("successed %s:%s" % (args['<name>'],
args["<value>"]))
else:
''
else:
''
else:
''
elif (args['env-path'] is True):
if (args['--add'] == True):
if (args['<name>'] and args["<value>"] is not None):
config["add-path-to-env"][args['<name>']] = args[
"<value>"]
print ( "successed %s:%s" % (args['<name>'],
args[ "<value>"]))
else:
''
elif (args['--del'] == True):
if (args["<name>"] is not None):
if (config['add-path-to-env'].__contains__(
args['<name>'])):
config["add-path-to-env"].__delitem__(
args['<name>'])
print ("successed %s" % (args['<name>']))
else:
''
else:
''
elif (args['--mod'] == True):
if (args['<name>'] and args["<value>"] is not None):
if (config['add-path-to-env'].__contains__(
args['<name>'])):
config["add-path-to-env"][args['<name>']] = \
args["<value>"]
print ("successed %s:%s" % (args['<name>'],
args["<value>"]))
else:
''
else:
''
else:
''
elif (args['cmd'] is True):
if (args['--add'] == True):
if (args['<name>'] and args["<value>"] is not None):
config["store-named-command"][args['<name>']] = args[
"<value>"]
print ( "successed %s:%s" % (args['<name>'],
args[ "<value>"]))
else:
''
elif (args['--del'] == True):
if (args["<name>"] is not None):
if (config['store-named-command'].__contains__(
args['<name>'])):
config["store-named-command"].__delitem__(
args['<name>'])
print ("successed %s" % (args['<name>']))
else:
''
else:
''
elif (args['--mod'] == True):
if (args['<name>'] and args["<value>"] is not None):
if (config['store-named-command'].__contains__(
args['<name>'])):
config["store-named-command"][args['<name>']] = \
args["<value>"]
print ("successed %s:%s" % (args['<name>'],
args["<value>"]))
else:
''
else:
''
else:
''
else:
''
elif (args['stream'] is True):
if (args['--add'] == True):
if (args['<name>'] and args["<values>"] is not None):
config["execute-stream"][args['<name>']] = args[
"<values>"]
print ("successed %s:%s" % (args['<name>'],
args["<values>"]))
else:
''
elif (args['--del'] == True):
if (args["<name>"] is not None):
if (config['execute-stream'].__contains__(
args['<name>'])):
config["execute-stream"].__delitem__(
args['<name>'])
print ("successed %s" % (args['<name>']))
else:
''
else:
''
elif (args['--mod'] == True):
if (args['<name>'] and args["<values>"] is not None):
config["execute-stream"][args['<name>']] = args[
"<values>"]
print ("successed %s:%s" % (args['<name>'],
args["<values>"]))
else:
''
else:
''
else:
''
#print(config)
writeJsonData(file, config)
break
def read_thread_function(p):
''
code = (codecs.lookup(locale.getpreferredencoding()).name)
while(True):
l = p.stdout.readline().rstrip().decode(code)
if (l is None):
#print ('ddd')
break
if(p.poll() is not None):
#print("eee")
break
print (l)
#print (l)
#stdout.flush()
def read_stderr_thread_function(p):
''
code = (codecs.lookup(locale.getpreferredencoding()).name)
while(True):
l = p.stderr.readline().rstrip().decode(code)
if (l is None):
#print ('ddd')
break
if(p.poll() is not None):
#print("eee")
break
print (l)
#print (l)
#stdout.flush()
def write_thread_function(list0):
''
### config -> raw config
rawconfig = config.copy()
#print ( rawconfig )
env = os.environ
for (key, value) in rawconfig["env-variables"].items():
#print (key) #...
startpos = 0
while (True):
#print (startpos)
index = value.find('${', startpos)
if (index == -1):
break
index2 = value.find('}', index)
startpos = index2
key0 = value[index:index2 + 1]
#print ( key0 ) #${...}
key1 = key0.split('{')[1].split('}')[0].strip()
#print ( key1 ) #...
if (env.has_key(key1)):
rawconfig["env-variables"][key] = rawconfig["env-variables"][key].replace(key0, env[key1])
else:
for (key2, value2) in config["env-variables"].items():
if (key2 == key1):
rawconfig["env-variables"][key] = rawconfig["env-variables"][key].replace(key0, rawconfig["env-variables"][key1])
#print ("%s:%s" % (key, rawconfig["env-variables"][key]))
else:
''
for (key, value) in rawconfig["store-named-command"].items():
#print (key) #...
startpos = 0
while (True):
#print (startpos)
index = value.find('${', startpos)
if (index == -1):
break
index2 = value.find('}', index)
startpos = index2
key0 = value[index:index2 + 1]
#print ( key0 ) #${...}
key1 = key0.split('{')[1].split('}')[0].strip()
#print ( key1 ) #...
if (env.has_key(key1)):
rawconfig["store-named-command"][key] = rawconfig["store-named-command"][key].replace(key0, env[key1])
else:
for (key2, value2) in rawconfig["env-variables"].items():
if (key2 == key1):
rawconfig["store-named-command"][key] = rawconfig["store-named-command"][key].replace(key0, rawconfig["env-variables"][key1])
#print ("%s:%s" % (key, rawconfig["store-named-command"][key]))
else:
''
while ( True ):
if( args['exec'] == True):
if(args['<stream-names>'] is not None):
env = os.environ
for (key, value) in rawconfig["env-variables"].items():
env[key] = value
for (key, value) in env.items():
#print ("%-24s %s" % (key, value) )
''
for (name, path) in rawconfig["add-path-to-env"].items():
env["PATH"] = path + os.path.pathsep + env["PATH"]
#print(env["PATH"].replace(os.path.pathsep, '\n'))
list0 = []
for stream in args['<stream-names>']:
if (rawconfig["execute-stream"].__contains__(stream)):
for cmd in rawconfig["execute-stream"][stream]:
if (rawconfig['store-named-command'].__contains__(cmd)):
# print("execute %s %s %s" % (stream, cmd, rawconfig['store-named-command'][cmd]))
list0.append( rawconfig['store-named-command'][cmd] )
else:
print ("can't find command %s" % cmd)
else:
print ("can't find stream %s" % stream)
list0.append("exit 0")
#print (list0)
shell = pwd.getpwuid(os.getuid()).pw_shell
if shell is None: shell = os.environ.get( 'SHELL' )
if shell is None: shell = os.environ.get( 'COMSPEC' )
#print ( 'Running under', shell )
p = subprocess.Popen(shell, shell = True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
read_thread = threading.Thread(target=read_thread_function, args=(p,))
read_thread.start()
read_err_thread = threading.Thread(target=read_stderr_thread_function, args=(p,))
read_err_thread.start()
write_thread = threading.Thread(target=write_thread_function, args=(list0,))
#write_thread.start()
time.sleep(1)
for cmd in list0:
#print ("command:%s" % cmd)
p.stdin.write(cmd + '\n')
p.stdin.flush()
#p.stdin.write("ping 127.0.0.1 -c 2 \n")
#p.stdin.flush()
p.wait()
#read_thread.close()
time.sleep(1)
#return
else:
print ("stream-names is none")
else:
''
break
return
if __name__ == '__main__':
main_function()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。