示例#1
0
def run():
	sys.path.append('lib')
	sys.path.append('lib/py')

	if len(sys.argv)<2:
		print_help()
		return

	cmd = sys.argv[1]

	if cmd=='build':
		from py import build
		build.run()

		vc = version.VersionControl()
		print 'version %s' % vc.repo.get_value('last_version_number')
				
	elif cmd=='merge':
		vc = version.VersionControl()
		vc.setup_master()
		vc.merge(vc.repo, vc.master)
		vc.close()

	elif cmd=='merge-local':
		vc = version.VersionControl()
		vc.setup_master()
		vc.merge(vc.master, vc.repo)
		vc.close()

	elif cmd=='setup':
		setup()
		
	elif cmd=='clear_startup':
		# experimental
		from webnotes import startup
		startup.clear_info('all')

		vc = version.VersionControl()
		print 'version %s' % vc.repo.get_value('last_version_number')
		
	elif cmd=='log':
		vc = version.VersionControl()
		for l in vc.repo.sql("select * from log order by rowid desc limit 10 ", as_dict =1):
			print 'file:'+ l['fname'] + ' | version: ' + l['version']
		print 'version %s' % vc.repo.get_value('last_version_number')
		vc.close()
		
	elif cmd=='files':
		vc = version.VersionControl()
		for f in vc.repo.sql("select fname from files where fname like ?", ((sys.argv[2] + '%'),)):
			print f[0]
		vc.close()
	
	# pull from remote and merge with local
	elif cmd=='gitpull':
		branch = 'master'
		if len(sys.argv)>2:
			branch = sys.argv[2]

		print "pulling erpnext"
		os.system('git pull origin %s' % branch)
		vc = version.VersionControl()
		vc.setup_master()
		vc.merge(vc.master, vc.repo)
		vc.close()

		print "pulling framework"
		os.chdir('lib')
		os.system('git pull origin %s' % branch)
示例#2
0
文件: wnf.py 项目: ant0nk/wnframework
def run():
    sys.path.append('lib')
    sys.path.append('lib/py')
    import webnotes
    import webnotes.defs
    sys.path.append(webnotes.defs.modules_path)

    if len(sys.argv) < 2:
        print_help()
        return

    cmd = sys.argv[1]

    if cmd == 'watch':
        from py import build
        import time

        while True:
            build.run()

            vc = version.VersionControl()
            print 'version %s' % vc.repo.get_value('last_version_number')
            time.sleep(5)

    elif cmd == 'build':
        from py import build
        build.run()

        vc = version.VersionControl()
        print 'version %s' % vc.repo.get_value('last_version_number')

    elif cmd == 'merge':
        vc = version.VersionControl()
        vc.setup_master()
        vc.merge(vc.repo, vc.master)
        vc.close()

    elif cmd == 'merge-local':
        vc = version.VersionControl()
        vc.setup_master()
        vc.merge(vc.master, vc.repo)
        vc.close()

    elif cmd == 'setup':
        setup()

    elif cmd == 'clear_startup':
        # experimental
        from webnotes import startup
        startup.clear_info('all')

        vc = version.VersionControl()
        print 'version %s' % vc.repo.get_value('last_version_number')

    elif cmd == 'log':
        vc = version.VersionControl()
        for l in vc.repo.sql("select * from log order by rowid desc limit 10 ",
                             as_dict=1):
            print 'file:' + l['fname'] + ' | version: ' + l['version']
        print 'version %s' % vc.repo.get_value('last_version_number')
        vc.close()

    elif cmd == 'files':
        vc = version.VersionControl()
        for f in vc.repo.sql("select fname from files where fname like ?",
                             ((sys.argv[2] + '%'), )):
            print f[0]
        vc.close()

    # pull from remote and merge with local
    elif cmd == 'gitpull':
        branch = 'master'
        if len(sys.argv) > 2:
            branch = sys.argv[2]

        print "pulling erpnext"
        os.system('git pull origin %s' % branch)
        vc = version.VersionControl()
        vc.setup_master()
        vc.merge(vc.master, vc.repo)
        vc.close()

        print "pulling framework"
        os.chdir('lib')
        os.system('git pull origin %s' % branch)

    # replace code
    elif cmd == 'replace':
        replace_code('.', sys.argv[2], sys.argv[3], sys.argv[4])

    elif cmd == 'patch':
        from webnotes.modules.patch_handler import run
        if len(sys.argv) > 2 and sys.argv[2] == '-f':
            # force patch
            run(patch_list=sys.argv[3:], overwrite=1, log_exception=0)
        else:
            # run patch once
            run(patch_list=sys.argv[2:], log_exception=0)
示例#3
0
def run():
	sys.path.append('lib')
	sys.path.append('lib/py')
	import webnotes
	import webnotes.defs
	sys.path.append(webnotes.defs.modules_path)

	if len(sys.argv)<2:
		print_help()
		return

	cmd = sys.argv[1]

	if cmd=='watch':
		from py import build
		import time
		
		while True:
			build.run()

			vc = version.VersionControl()
			print 'version %s' % vc.repo.get_value('last_version_number')
			time.sleep(5)
			

	elif cmd=='build':
		from py import build
		build.run()

		vc = version.VersionControl()
		print 'version %s' % vc.repo.get_value('last_version_number')
				
	elif cmd=='merge':
		vc = version.VersionControl()
		vc.setup_master()
		vc.merge(vc.repo, vc.master)
		vc.close()

	elif cmd=='merge-local':
		vc = version.VersionControl()
		vc.setup_master()
		vc.merge(vc.master, vc.repo)
		vc.close()

	elif cmd=='setup':
		setup()
		
	elif cmd=='clear_startup':
		# experimental
		from webnotes import startup
		startup.clear_info('all')

		vc = version.VersionControl()
		print 'version %s' % vc.repo.get_value('last_version_number')
		
	elif cmd=='log':
		vc = version.VersionControl()
		for l in vc.repo.sql("select * from log order by rowid desc limit 10 ", as_dict =1):
			print 'file:'+ l['fname'] + ' | version: ' + l['version']
		print 'version %s' % vc.repo.get_value('last_version_number')
		vc.close()
		
	elif cmd=='files':
		vc = version.VersionControl()
		for f in vc.repo.sql("select fname from files where fname like ?", ((sys.argv[2] + '%'),)):
			print f[0]
		vc.close()
	
	# pull from remote and merge with local
	elif cmd=='gitpull':
		branch = 'master'
		if len(sys.argv)>2:
			branch = sys.argv[2]

		print "pulling erpnext"
		os.system('git pull origin %s' % branch)
		vc = version.VersionControl()
		vc.setup_master()
		vc.merge(vc.master, vc.repo)
		vc.close()

		print "pulling framework"
		os.chdir('lib')
		os.system('git pull origin %s' % branch)

	# replace code
	elif cmd=='replace':
		replace_code('.', sys.argv[2], sys.argv[3], sys.argv[4])
		
	elif cmd=='patch':
		from webnotes.modules.patch_handler import run
		if len(sys.argv)>2 and sys.argv[2]=='-f':
			# force patch
			run(patch_list = sys.argv[3:], overwrite=1, log_exception=0)
		else:
			# run patch once
			run(patch_list = sys.argv[2:], log_exception=0)
示例#4
0
def run():
	sys.path.append('lib')
	sys.path.append('lib/py')
	import webnotes
	import webnotes.defs
	sys.path.append(webnotes.defs.modules_path)

	if len(sys.argv)<2:
		print_help()
		return

	cmd = sys.argv[1]

	if cmd=='watch':
		from py import build
		import time
		
		while True:
			build.run()

			vc = version.VersionControl()
			print 'version %s' % vc.repo.get_value('last_version_number')
			time.sleep(5)
			

	elif cmd=='build':
		from py.build.project import Project
		Project().build()
		
	# replace code
	elif cmd=='replace':
		replace_code('.', sys.argv[2], sys.argv[3], sys.argv[4])
		
	elif cmd=='patch':
		from optparse import OptionParser
		parser = OptionParser()
		parser.add_option("-q", "--quiet",
						  action="store_false", dest="verbose", default=True,
						  help="Do not print status messages to stdout")
		parser.add_option("-l", "--latest",
						  action="store_true", dest="run_latest", default=False,
						  help="Apply the latest patches")
		parser.add_option("-p", "--patch", dest="patch_list", metavar='PATCH_MODULE.PATCH_FILE',
						  action="append",
						  help="Apply patch PATCH_MODULE.PATCH_FILE")
		parser.add_option("-f", "--force",
						  action="store_true", dest="force", default=False,
						  help="Force Apply all patches specified using option -p or --patch")
		parser.add_option("-d", "--db",
						  dest="db_name",
						  help="Apply the patches on given db")
		(options, args) = parser.parse_args()
		
		if options.patch_list:
			for patch in options.patch_list:
				patch_split = patch.split(".")
				idx = options.patch_list.index(patch)
				patch_module = ".".join(patch_split[:-1])
				options.patch_list[idx] = {
					'patch_module': patch_module or "patches",
					'patch_file': patch_split[-1]
				}
		kwargs = options.__dict__
		from webnotes.modules.patch_handler import PatchHandler
		PatchHandler(db_name=kwargs.get('db_name') or getattr(webnotes.defs, 'default_db_name'), verbose=kwargs.get('verbose')).run(**kwargs)