예제 #1
0
def copy_files(src_glob_raw, destination_folder_raw):
	SystemLogger.info("copying files from " + src_glob_raw + " to " + destination_folder_raw)
	expanded_folder = os.path.expandvars (destination_folder_raw)
	for fname in glob.iglob(os.path.expandvars (src_glob_raw)):
		dst_file = os.path.join(expanded_folder, os.path.basename(fname))
		SystemLogger.debug ("copying file from " + fname + " to " + dst_file)
		shutil.copy(fname, dst_file)
예제 #2
0
	def clean (self):
		l_path = os.path.join (self._project_path, "EIFGENs", self._target)
		SystemLogger.info ("Cleaning Eiffel program at " + l_path)
		elocation.delete (l_path)
		l_path = os.path.dirname (l_path)
		if os.listdir (l_path) == []:
			elocation.delete (l_path)
예제 #3
0
def catalog(catalog, keep_all):
    if catalog == None:
        catalog = "autogen"
    l_command = _set_eweasel_env()
    l_catalog = _prepare_catalog(catalog)
    assert os.path.exists(l_catalog), "Catalog does not exist."
    SystemLogger.info("Running Eweasel on catalog: " + l_catalog)
    _invoke_eweasel(l_command, l_catalog, keep_all)
예제 #4
0
파일: eve.py 프로젝트: boxer41a/estudioctl
def main():
	mode = 'default'
	submode = None
	if (len(sys.argv) > 1):
		mode = sys.argv[1]
	if (len(sys.argv) > 2):
		submode = sys.argv[2]

	if mode == 'default':
		print('usage:\n'
			'  eve.py update --- Update or install EiffelStudio; update and compile EVE.\n'
			'  eve.py finalize eve --- Finalize EVE.\n'
			'  eve.py eve --- Launch finalized EVE.\n'
			'  eve.py es --- Launch EiffelStudio.\n')
	elif mode == 'es':
		run_eiffel_studio()
	elif mode == 'eve':
		run_eve()
	elif mode == 'check':
		if not check_environment_variables():
			update_environment_variables()
	elif mode == 'update' and submode == None:
		update_EiffelStudio()
		esvn.update_repository(config.v_url_svn_trunk_src, elocation.trunk_source())
		compile_runtime()
		compile_eve('bench')
	elif mode == 'update' and (submode == 'EiffelStudio' or submode == 'es'):
		update_EiffelStudio()
	elif mode == 'update' and submode == 'source':
		esvn.update_repository(config.v_url_svn_trunk_src, elocation.trunk_source())
	elif mode == 'compile' and submode == 'runtime':
		if not check_environment_variables():
			update_environment_variables()
		ecompile.compile_runtime()
	elif mode == 'compile' and (submode == None or submode == 'eve'):
		if not check_environment_variables():
			update_environment_variables()
		#compile_eve('bench')
		compile_eve ('batch', 'ecb')
	elif mode == 'finalize' and (submode == None or submode == 'eve'):
		if not check_environment_variables():
			update_environment_variables()
		#finalize_eve('bench')
		finalize_eve ('batch', 'ecb')
	elif mode == 'delivery':
		if not check_environment_variables():
			update_environment_variables()
		make_delivery()
	elif mode == 'merge':
		make_merge()
	elif mode == 'eweasel':
		eweasel.main (sys.argv[1:])
	else:
		if submode == None:
			SystemLogger.error("invalid option " + mode)
		else:
			SystemLogger.error("invalid option " + mode + " / " + submode)
	return
예제 #5
0
파일: esvn.py 프로젝트: boxer41a/estudioctl
def merge(path, url, rev_start, rev_end):
	"""Merge repository at path with repository at url"""
	source_path = os.path.realpath(path)
	SystemLogger.debug("SVN merge")
	SystemLogger.debug("Path: " + source_path)
	SystemLogger.debug("URL: " + url)
	SystemLogger.debug("Revision from: " + str(rev_start))
	SystemLogger.debug("Revision to: " + str(rev_end))
	svn.merge_peg(url, rev_start, rev_end, rev_end, source_path)
예제 #6
0
def fix_makefiles (src_glob_raw, link_command):
	for orig in glob.iglob(os.path.expandvars (src_glob_raw)):
		SystemLogger.info ("Fixing makefile: " + orig)
		fixed = orig + ".tmp"
		with open (fixed, 'w') as fixed_file:
			with open (orig) as orig_file:
				for line in orig_file:
					fixed_file.write (line.replace ('LINKCMD    = $(CC)', 'LINKCMD    = ' + link_command))
		elocation.delete (orig)
		elocation.move (fixed, orig)
예제 #7
0
def main(args):
    mode = "default"
    argument = None
    keep = False

    if len(args) > 1:
        mode = args[1]
    if len(args) > 2:
        argument = args[2]

    if mode == "default":
        print(
            "usage:\n"
            "  eweasel.py update                          --- Update the source code of eweasel. \n"
            "  eweasel.py install                         --- Compile the eweasel binary and set everything up.\n"
            "  eweasel.py precompile [library]            --- Precompile the specified library, or all libraries if argument omitted.\n"
            "  eweasel.py run [--keep] filter...          --- Run the tests with the specified filter. If --keep is present, also keeps passing tests.\n"
            "  eweasel.py catalog [--keep] [catalog_name] --- Run eweasel with the specified catalog..\n"
            "                                             --- If the catalog is in the BUILD directory and has the extension .eweasel_catalog,\n"
            "                                             --- the full path and file name extension can be omitted.\n"
            '                                             --- If no catalog is specified, it will default to "autogen.eweasel_catalog" in the BUILD directory.\n'
            "  eweasel.py generate catalog_name filter... --- Create a catalog with name catalog_name for the specified filter.\n"
            "                                             --- The catalog will be stored in the BUILD directory with the extension .eweasel_catalog.\n"
        )

    elif mode == "update":
        update()
    elif mode == "install":
        set_environment()
        install()
    elif mode == "precompile":
        set_environment()
        precompile(argument)
    elif mode == "catalog":
        if argument == "--keep":
            keep = True
            argument = None
            if len(args) > 3:
                argument = args[3]
        set_environment()
        catalog(argument, keep)
    elif mode == "run":
        set_environment()
        if argument == "--keep":
            keep = True
            generate(" ".join(args[3:]), "autogen")
        else:
            generate(" ".join(args[2:]), "autogen")
        catalog("autogen", keep)
    elif mode == "generate":
        assert argument != None, "Must provide argument"
        generate(" ".join(sys.argv[3:]), argument)
    else:
        SystemLogger.error("invalid option " + mode)
    return
예제 #8
0
def generate(a_filter, name="autogen"):
    l_parser = boolean.Parser(a_filter)
    l_filter = l_parser.parse()
    l_target_path = os.path.join(elocation.build(), name + ".eweasel_catalog")
    SystemLogger.info("Creating catalog " + l_target_path + " with filter: " + l_filter.to_string())
    with open(_prepare_catalog(None), "r") as source:
        with open(l_target_path, "w") as target:
            target.write("source_path $BUGS\n")
            for line in source:
                if l_filter.evaluate(line):
                    print(line.rstrip())
                    target.write(line)
예제 #9
0
def precompile(target):
    if target == "all" or target == None:
        precompile("base")
        precompile("base-safe")
        precompile("base-mt")
        precompile("base-scoop-safe")
    else:
        l_path = os.path.expandvars(os.path.join("$ISE_EIFFEL", "precomp", "spec", "$ISE_PLATFORM", target + ".ecf"))
        l_project = ecompile.EiffelProject(l_path, target, "driver")
        if l_project.precompile():
            SystemLogger.success("Precompilation of " + target + " successful.")
        else:
            SystemLogger.error("Precompilation of " + target + " failed.")
예제 #10
0
파일: esvn.py 프로젝트: boxer41a/estudioctl
def checkout(url, path):
	"""Checkout HEAD revision from url to path"""
	global svn, svn_helper_revision, _has_pysvn
	SystemLogger.debug("SVN: checkout from " + url + " to " + path)
	if _has_pysvn:
		svn.checkout(url, path)
		revision = svn_helper_revision
	else:
		output = subprocess.check_output(['svn', 'checkout', url, path]).decode(v_encoding)
		expr = re.compile(r'.*Checked out revision\s([\d]+).*')
		revision = expr.search(output).group(1)
	SystemLogger.debug("SVN: revision " + str(revision))
	return revision
예제 #11
0
파일: eve.py 프로젝트: boxer41a/estudioctl
def run_eve():
	# Select EiffelStudio (or install if not available)
	current_version, current_path = get_installed_version()
	if current_version == -1:
		update_EiffelStudio()
		current_version, current_path = get_installed_version()
	# Update Environment variables
	update_environment_variables()
	os.environ["ISE_PRECOMP"] = os.path.join(v_dir_eve_source, "Delivery", "precomp", "spec", "platform"); #TODO
	# Run EiffelStudio
	exe_path = os.path.realpath(os.path.join(v_dir_eve_source, "Eiffel", "Ace", "EIFGENs", "bench", "F_code", d_eve_exe_name)) #TODO
	if os.path.isfile(exe_path):
		execute([exe_path, '-gui'])
	else:
		SystemLogger.error("Finalized eve executable does not exist (" + exe_path + ").")
예제 #12
0
파일: eve.py 프로젝트: boxer41a/estudioctl
def execute(program, output_file = None, execution_directory = None):
	SystemLogger.debug("Executing " + ' '.join(program))
	if isinstance(output_file, str):
		pipe = open(output_file, 'a')
	else:
		pipe = output_file
	if execution_directory is None:
		proc = subprocess.Popen(program, stdin=pipe, stdout=pipe, stderr=pipe)
	else:
		proc = subprocess.Popen(program, cwd=execution_directory, stdin=pipe, stdout=pipe, stderr=pipe)
	proc.communicate()
	if isinstance(output_file, str):
		pipe.close()
	SystemLogger.debug("Finished with code " + str(proc.returncode))
	return proc.returncode
예제 #13
0
파일: esvn.py 프로젝트: boxer41a/estudioctl
def update(path, force=False):
	"""Update repository at local path"""
	global svn, _has_pysvn
	SystemLogger.debug("SVN: updating repository at " + path)
	if _has_pysvn:
		if not is_up_to_date(path) or force:
			revision = svn.update(path)[0].number
		else:
			revision = info_local_revision_number(path)
	else:
		output = subprocess.check_output(['svn', 'update', path]).decode(v_encoding)
		expr = re.compile(r'.*revision\s([\d]+).*')
		revision = expr.search(output).group(1)
	SystemLogger.debug("SVN: revision " + str(revision))
	return revision
예제 #14
0
파일: eve.py 프로젝트: boxer41a/estudioctl
def replace_in_file(path, search, replace):
	SystemLogger.debug("Replacing in file")
	SystemLogger.debug("Path: " + path)
	SystemLogger.debug("Search: " + search)
	SystemLogger.debug("Replace: " + replace)
	import fileinput
	for line in fileinput.FileInput(path, inplace=1):
		line = line.replace(search, replace)
		print (line),
예제 #15
0
파일: eve.py 프로젝트: boxer41a/estudioctl
def send_mail(to, subject, text, attach=None):
	"""Send email"""
	SystemLogger.info("Sending email '" + subject + "' to " + str(to))
	if to != None:
		email_user = "******"
		msg = MIMEMultipart()
		msg['From'] = "EVE <" + email_user + ">"
		msg['To'] = to
		msg['Subject'] = subject
		msg.attach(MIMEText(text))
		if attach != None:
			part = MIMEBase('application', 'octet-stream')
			part.set_payload(open(attach, 'rb').read())
			Encoders.encode_base64(part)
			part.add_header('Content-Disposition', 'attachment; filename="%s"' % os.path.basename(attach))
			msg.attach(part)
		mailServer = smtplib.SMTP("smtp0.ethz.ch", 25, "localhost")
		mailServer.sendmail(email_user, to, msg.as_string())
		mailServer.quit()
예제 #16
0
파일: eve.py 프로젝트: boxer41a/estudioctl
def update_environment_variables():
	# ISE_PLATFORM
	if not "ISE_PLATFORM" in os.environ or os.getenv("ISE_PLATFORM") != d_ise_platform:
		set_persistent_environment_variable("ISE_PLATFORM", d_ise_platform)
	# ISE_EIFFEL
	version, path = get_installed_version()
	if "ISE_EIFFEL" in os.environ and path == None:
		SystemLogger.debug ("WARNING: No nightly build available. Using ISE_EIFFEL = " + os.getenv("ISE_EIFFEL"))
	elif not "ISE_EIFFEL" in os.environ or os.getenv("ISE_EIFFEL") != path:
		set_persistent_environment_variable("ISE_EIFFEL", path)
#	else:
#		raise Exception ("Could not set ISE_EIFFEL environment variable.")
	# ISE_C_COMPILER
	if not "ISE_C_COMPILER" in os.environ or os.getenv("ISE_C_COMPILER") != d_ise_c_compiler:
		set_persistent_environment_variable("ISE_C_COMPILER", d_ise_c_compiler)
	# EIFFEL_SRC
	eiffel_source = os.path.realpath(elocation.trunk_source())
	if not "EIFFEL_SRC" in os.environ or os.getenv("EIFFEL_SRC") != eiffel_source:
		set_persistent_environment_variable("EIFFEL_SRC", eiffel_source)
	# EWEASEL
	if not "EWEASEL" in os.environ or os.getenv("EWEASEL") != elocation.eweasel():
		set_persistent_environment_variable("EWEASEL", elocation.eweasel())
	# ISE_LIBRARY
	eiffel_source = os.path.realpath(elocation.trunk_source())
	if not "ISE_LIBRARY" in os.environ or os.getenv("ISE_LIBRARY") != eiffel_source:
		set_persistent_environment_variable("ISE_LIBRARY", eiffel_source)
	# PATH: EiffelStudio
	# TODO: update PATH contents
	# Temporary path update for execution in same session
	os.environ['PATH'] = os.path.join(os.getenv("ISE_EIFFEL"), 'studio', 'spec', os.getenv("ISE_PLATFORM"), 'bin') + os.pathsep + os.environ['PATH']
	
	if platform.system() != "Windows":
            with open (os.path.join (elocation.base_directory(), 'scripts', 'nightly.unix.sh'), 'w') as l_file:
                l_file.write ('export ISE_EIFFEL=')
                l_file.write (path)
                l_file.write ('\n')
	return
예제 #17
0
def execute_with_output (program, execution_directory = None):
	SystemLogger.debug ("Executing " + ' '.join (program))
	if execution_directory is None:
		proc = subprocess.Popen(program, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
		for line in proc.stdout:
			SystemLogger.info (line.decode (v_encoding).rstrip())
	proc.wait()
	SystemLogger.info("Finished with code " + str(proc.returncode))
	return proc.returncode
예제 #18
0
파일: eve.py 프로젝트: boxer41a/estudioctl
def update_EiffelStudio():
	SystemLogger.info("Updating EiffelStudio")
	if v_force_es_version != None:
		SystemLogger.warning("Forcing EiffelStudio version " + v_force_es_version)
	name, filename, version, url = get_nightly_build(d_ise_platform, d_archive_extension)
	current_version, current_path = get_installed_version()
	if version > current_version or (v_force_es_version != None and current_version != v_force_es_version):
		target_file = os.path.join(v_dir_eiffelstudio_base, filename)
		download_file(url, target_file)
		eutils.extract(target_file)
		elocation.move(os.path.join('.', name), os.path.join(v_dir_eiffelstudio_base, name + '_' + str(version)))
		elocation.delete(target_file)
		update_environment_variables()
		current_version = version
		SystemLogger.success("EiffelStudio version " + str(version) + " installed")
	else:
		update_environment_variables()
		SystemLogger.success("EiffelStudio is up-to-date at version " + str(current_version))
	return current_version
예제 #19
0
def install():
    assert os.environ["ISE_EIFFEL"] != None, "ISE_EIFFEL is not set."
    assert os.environ["ISE_PLATFORM"] != None, "ISE_PLATFORM is not set."
    assert os.environ["ISE_LIBRARY"] != None, "ISE_LIBRARY is no set."
    assert os.environ["EWEASEL"] != None, "EWEASEL is not set."

    update()

    l_path = os.path.expandvars(os.path.join("$EWEASEL", "source", "eweasel.ecf"))
    l_project = ecompile.EiffelProject(l_path, "eweasel_mt", "eweasel-mt")
    if l_project.finalize():
        l_target_dir = os.path.expandvars(os.path.join("$EWEASEL", "spec", "$ISE_PLATFORM", "bin"))
        if not os.path.exists(l_target_dir):
            os.makedirs(l_target_dir)
        elocation.copy(l_project.last_result(), l_target_dir)
        l_project.clean()
        SystemLogger.success("Eweasel installation successful.")
        SystemLogger.warning("Make sure that $EWEASEL/spec/$ISE_PLATFORM/bin is in your PATH variable!")
    else:
        SystemLogger.error("Installation of eweasel failed.")
예제 #20
0
파일: esvn.py 프로젝트: boxer41a/estudioctl
def commit(path, message):
	"""Commit repository at path using the commit message"""
	SystemLogger.debug("SVN commit")
	SystemLogger.debug("Path: " + path)
	SystemLogger.debug("Message: " + message)
	svn.checkin(path, message)
예제 #21
0
def run_all(keep_all=False):
    SystemLogger.info("Running the full eweasel test suite.")
    _invoke_eweasel(_set_eweasel_env(), _prepare_catalog(None), keep_all)
예제 #22
0
def compress (path, basename=None):
	""" 
		Compress the file or directory at path 
		Argument path: Unicode string. 
		Argument basename: Name of the archive to be generated. Unicode string, can be None.
		Result: Path to the compressed file. Unicode string.
	"""
	SystemLogger.debug("Compressing path")
	SystemLogger.debug("Path: " + path)
	result = None
	if basename == None:
		basename = os.path.basename(path)
	if platform.system() == 'Windows':
		output_file = os.path.join('.', basename + '.' + config.d_archive_extension)
		SystemLogger.debug("Destination: " + output_file)
		# TODO: get path from registry
		executable = os.path.join('C:\\', 'Program Files', '7-zip', '7z.exe')
		if os.path.isfile(executable):
			if execute([executable, 'a', output_file, path], SystemLogger.get_file()) == 0:
				SystemLogger.debug("Compression complete")
				result = output_file
			else:
				SystemLogger.error("Compression of '" + path + "' failed")
		else:
			SystemLogger.error("Comperssion of '" + path + "' failed. 7zip executable not found at " + executable)
	else:
		output_file = os.path.realpath(os.path.join('.', basename + '.' + config.d_archive_extension))
		workingdir, compressdir = os.path.split(path)
		if execute(['tar', '-C', workingdir, '-cjf', output_file, compressdir], SystemLogger.get_file()) == 0:
			SystemLogger.debug("Compression complete")
			result = output_file
		else:
			SystemLogger.error("Compression of '" + path + "' failed")
	return result
예제 #23
0
def extract (a_file):
	""" 
		Extract a_file to the current directory.
		Argument a_file: Unicode string.
	"""
	SystemLogger.debug("Extracting file")
	SystemLogger.debug("Path: " + a_file)
	if platform.system() == 'Windows':
		# TODO: get path from registry
		executable = os.path.join('C:\\', 'Program Files', '7-zip', '7z.exe')
		if os.path.isfile(executable):
			if execute([executable, 'x', a_file], SystemLogger.get_file()) == 0:
				SystemLogger.debug("Extraction complete")
			else:
				SystemLogger.error("Extraction of '" + a_file + "' failed")
		else:
			SystemLogger.error("Extraction of '" + a_file + "' failed. 7zip executable not found at " + executable)
	else:
		if execute(['tar', '-xjf', a_file], SystemLogger.get_file()) == 0:
			SystemLogger.debug("Extraction complete")
		else:
			SystemLogger.error("Extraction of '" + a_file + "' failed")
예제 #24
0
파일: test.py 프로젝트: boxer41a/estudioctl
def main ():
	SystemLogger.success ("Starting tests.")
	#test_svn()
	test_location()
	test_compress()
예제 #25
0
파일: eve.py 프로젝트: boxer41a/estudioctl
def set_persistent_environment_variable(varname, value):
	SystemLogger.debug("setting environment variable " + varname + " to " + value)
	os.environ[varname] = value
	if platform.system() == 'Windows':
		execute(['setx', varname, value], SystemLogger.get_file())
	return
예제 #26
0
파일: eve.py 프로젝트: boxer41a/estudioctl
def make_delivery():
	SystemLogger.info("Generating new delivery")

	eve_version = esvn.info_local_revision_number(v_dir_eve_source) #TODO
	delivery_name = 'eve_' + str(eve_version)
	delivery_path = os.path.realpath(os.path.join(v_dir_delivery, delivery_name))
	# generate finalized version
	check_environment_variables()
	compile_runtime()
	update_version_number()
	finalize_eve('bench')
	revert_version_number()
	# copy EiffelStudio to delivery destination (this copies the runtime)
	elocation.copy(os.getenv("ISE_EIFFEL"), delivery_path)
	# copy finalized eve to delivery destination
	eve_exe_source = os.path.join(v_dir_eve_source, 'Eiffel', 'Ace', 'EIFGENs', 'bench', 'F_code', d_eve_exe_name)
	eve_exe_target = os.path.join(delivery_path, 'studio', 'spec', os.getenv("ISE_PLATFORM"), 'bin', d_eve_exe_name)
	elocation.copy(eve_exe_source, eve_exe_target)
	# AutoProof: copy update to base library
	source = os.path.join(v_dir_eve_source, 'library', 'base', 'eve')
	target = os.path.join(delivery_path, 'library', 'base', 'eve')
	elocation.copy(source, target)
	source = os.path.join(v_dir_eve_source, 'library', 'base', 'base2')
	target = os.path.join(delivery_path, 'library', 'base', 'base2')
	elocation.copy(source, target)
	source = os.path.join(v_dir_eve_source, 'library', 'base', 'mml')
	target = os.path.join(delivery_path, 'library', 'base', 'mml')
	elocation.copy(source, target)
	source = os.path.join(v_dir_eve_source, 'library', 'base', 'base-eve.ecf')
	target = os.path.join(delivery_path, 'library', 'base', 'base-eve.ecf')
	elocation.copy(source, target)
	# AutoProof: copy ecf for precompile
	source = os.path.join(v_dir_eve_source, 'Delivery', 'precomp', 'spec', 'platform', 'base-eve.ecf')
	target = os.path.join(delivery_path, 'precomp', 'spec', os.getenv("ISE_PLATFORM"), 'base-eve.ecf')
	elocation.copy(source, target)
	# AutoProof: copy Boogie files
	source = os.path.join(v_dir_eve_source, 'Delivery', 'studio', 'tools', 'autoproof')
	target = os.path.join(delivery_path, 'studio', 'tools', 'autoproof')
	elocation.copy(source, target)
	# copy Boogie to delivery destination
	boogie_target = os.path.join(delivery_path, 'studio', 'tools', 'boogie')
	elocation.copy(v_dir_boogie, boogie_target)
	# copy libraries to delivery destination
	source = os.path.join(v_dir_eve_source, 'library', 'fixing')
	target = os.path.join(delivery_path, 'library', 'fixing')
	elocation.copy(source, target)
# TODO
	# copy install/run scripts to destination
	source = os.path.join(v_dir_eve_source, 'Delivery', 'run_eve.bat')
	target = os.path.join(delivery_path, 'run_eve.bat')
	elocation.copy(source, target)
	source = os.path.join(v_dir_eve_source, 'Delivery', 'run_eve.py')
	target = os.path.join(delivery_path, 'run_eve.py')
	elocation.copy(source, target)
	# generate zip archive
	archive_path = eutils.compress(delivery_path, delivery_name + "-" + d_ise_platform)
	delivery_file = os.path.join(v_dir_delivery, os.path.basename(archive_path))
	elocation.move(archive_path, delivery_file)
	# clean up
	elocation.delete(delivery_path)
	SystemLogger.success("Delivery " + delivery_name + " finished")
	# upload zip to server
	result = None
	if os.path.exists(v_dir_delivery_remote):
		remote_file = os.path.join(v_dir_delivery_remote, os.path.basename(delivery_file))
		elocation.copy(delivery_file, remote_file)
		SystemLogger.success("Delivery copied to remote location")
		result = v_remote_base_url + '/' + os.path.basename(delivery_file)
	else:
		if v_dir_delivery_remote != None:
			SystemLogger.error("Remote location (" + v_dir_delivery_remote + ") does not exist")
	return result
예제 #27
0
파일: esvn.py 프로젝트: boxer41a/estudioctl
import sys
v_encoding = sys.stdout.encoding

# Import pysvn if available.
try:
	import pysvn
	_has_pysvn = True
except ImportError:
	try:
		if subprocess.call(['svn', 'help'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0:
			_has_cmdsvn = True
				# We can only parse english output, so make sure we get it from SVN.
			os.environ['LC_MESSAGES']='en'
		else:
			SystemLogger.error("pysvn module is not available. SVN command line not available. All SVN operations are disabled.")
	except OSError:
		SystemLogger.error("pysvn module is not available. SVN command line not available. All SVN operations are disabled.")


def svn_get_login(realm, username, may_save):
	return True, v_svn_user, v_svn_password, False

def ssl_server_trust_prompt(trust_dict):
	"""Helper function to ignore any SSL trust errors"""
	return True, trust_dict['failures'], True

svn_helper_revision = -1
def svn_notify(arg):
	global svn_helper_revision
	if arg['action'] == pysvn.wc_notify_action.update_completed:
예제 #28
0
파일: eve.py 프로젝트: boxer41a/estudioctl
def make_merge():
	global v_dir_eve_source

	# set up parameters
	merge_path = os.path.realpath(v_dir_merge)
	v_dir_eve_source = os.path.join(merge_path, 'Src')
	os.environ['EIFFEL_SRC'] = v_dir_eve_source
	os.environ['ISE_LIBRARY'] = v_dir_eve_source

	# update dependencies
	update_EiffelStudio()

	# update repository
	try:
		elocation.delete(merge_path)
		esvn.update_repository(v_url_svn_eve, merge_path)
	except Exception as e1:
		SystemLogger.warning("Checkout failed. Trying one more time.")
		send_mail(v_email_merge_info, "[EVE] WARNING: checkout failed", "I will try again.")
		try:
			elocation.delete(merge_path)
			esvn.update_repository(v_url_svn_eve, merge_path)
		except Exception as e2:
			SystemLogger.error("Checkout failed, again...")
			send_mail(v_email_merge_info, "[EVE] ERROR: checkout failed again", "I give up...")
			sys.exit(0)

	# send email to block commits
	send_mail(v_email_merge_update, '[EVE] merge started', """Dear assistants,

The eve branch is being synchronized with the trunk.
Please do not commit to the eve branch until the synchronization is complete.

Regards,
EVE""")

	# merge
	trunk_revision = esvn.info_remote_revision_number(v_url_svn_trunk)
	last_merge_revision = esvn.last_merge_revision_number(v_url_svn_eve)
	esvn.merge(merge_path, v_url_svn_trunk, pysvn.Revision(pysvn.opt_revision_kind.number, last_merge_revision), pysvn.Revision(pysvn.opt_revision_kind.number, trunk_revision))

	# wait for conflicts to be resolved
	success = not esvn.has_conflicts(merge_path)
	first = True
	while not success:
		if first:
			first = False
			SystemLogger.error("Merge has produced conflicts")
			send_mail(v_email_merge_info, "[EVE] WAITING: merge produced conflicts", "Resolve conflicts manually and then continue script.")
		else:
			SystemLogger.error("There are still conflits!")
		print ("---")
		print ("Press enter when conflicts are resolved.")
		input()
		success = not esvn.has_conflicts(merge_path)
	SystemLogger.success("Merge successful")

	# compile
	check_environment_variables()
	compile_runtime()
	compile_eve('bench')
	
	# wait for compilation to be successful
	success = is_eve_compilation_successful('bench')
	first = True
	while not success:
		if first:
			first = False
			SystemLogger.error("EVE compilation failed")
			send_mail(v_email_merge_info, "[EVE] WAITING: EVE compilation failed", "Solve compilation problems manually and then continue script.")
		else:
			SystemLogger.error("compilation still fails!")
		print ("---")
		print ("Press enter when compilation problems are resolved.")
		input()
		if not is_eve_compilation_successful('bench'):
			compile_runtime()
			compile_eve('bench')
		success = is_eve_compilation_successful('bench')
	SystemLogger.success("Compilation successful")

	# commit
	message = "<<Merged from trunk#" + str(trunk_revision) + ".>>"
	esvn.commit(merge_path, message)
	first = True
	esvn.update (merge_path, True)
	while esvn.info_local_revision_number(merge_path) <= trunk_revision and False: #???
		if first:
			first = False
			SystemLogger.error("EVE commit failed")
			send_mail(v_email_merge_info, "[EVE] WAITING: commit failed", "Commit manually and then continue script.")
		else:
			SystemLogger.error("Local revision (" + str(esvn.info_local_revision_number(merge_path)) + ") still smaller than TRUNK (" + str(trunk_revision) + ")")
		print ("---")
		print ("Press enter when you have commited the repository manually.")
		print ("Commit message: " + message)
		input()
		esvn.update (merge_path, true)
	SystemLogger.success("Commit successful")
	
	# make delivery
	delivery_url = make_delivery()
	version, path = get_installed_version()

	# send email
	if delivery_url == None:
		send_mail(v_email_merge_update, "[EVE] merge completed with trunk#" + str(trunk_revision) + ".", """Dear assistants,

The eve branch is now synchronized with trunk#""" + str(trunk_revision) + """ using EiffelStudio """ + str(version) + """.
You can now update your checkout of eve and commit again.

Regards,
EVE""")
		send_mail(v_email_merge_info, "[EVE] Delivery creation failed", "See log for more information.")
	else:
		send_mail(v_email_merge_update, "[EVE] merge completed with trunk#" + str(trunk_revision) + " and new delivery available.", """Dear assistants,

The eve branch is now synchronized with trunk#""" + str(trunk_revision) + """ using EiffelStudio """ + str(version) + """.
You can now update your checkout of eve and commit again.

A """ + d_ise_platform + """ delivery of EVE has been created and is available at
  """ + delivery_url + """

Regards,
EVE""")
예제 #29
0
파일: esvn.py 프로젝트: boxer41a/estudioctl
def update_repository(url, path):
	"""Update repository at given path. If no checkout exists, do a new checkout from given url."""
	revision = -1
	if os.path.exists(path):
		SystemLogger.info("Updating repository")
		SystemLogger.info("Path: " + path)
		remote_url = info_remote_url(path)
		if url == remote_url:
			revision = info_local_revision_number(path)
			remote_revision = info_remote_revision_number(url)
			SystemLogger.debug("Local revision: " + str(revision))
			SystemLogger.debug("Remote revision: " + str(remote_revision))
			if revision == remote_revision:
				SystemLogger.success("Repository '" + path + "' is up-to-date at revision " + str(revision))
			else:
				revision = update(path)
				SystemLogger.success("Repository '" + path + "' is updated to revision " + str(revision))
		else:
			SystemLogger.error("Repository URL of existing directory '" + path + "'  does not match expected remote url")
			SystemLogger.error("Existing URL: " + remote_url)
			SystemLogger.error("Expected URL: " + url)
	else:
		SystemLogger.info("Checking out repository")
		SystemLogger.info("URL: " + url)
		SystemLogger.info("Location: " + path)
		revision = checkout(url, path)
		SystemLogger.success("Checkout of revision " + str(revision) + " complete")
	return revision 
예제 #30
0
파일: eve.py 프로젝트: boxer41a/estudioctl
def check_environment_variables():
	result = True
	# ISE_PLATFORM
	if not "ISE_PLATFORM" in os.environ:
		SystemLogger.error("Environment variable ISE_PLATFORM not set")
		result = False
	elif os.getenv("ISE_PLATFORM") != d_ise_platform:
		SystemLogger.error("Value of environment variable ISE_PLATFORM (" + os.getenv("ISE_PLATFORM") + ") should be '" + d_ise_platform + "'")
		result = False
	else:
		SystemLogger.debug("ISE_PLATFORM = " + os.getenv("ISE_PLATFORM"))
	# ISE_EIFFEL
	if not "ISE_EIFFEL" in os.environ:
		SystemLogger.error("Environment variable ISE_EIFFEL not set")
		result = False
	elif not os.path.isdir(os.getenv("ISE_EIFFEL")):
		SystemLogger.error("Path from environment variable ISE_EIFFEL (" + os.getenv("ISE_EIFFEL") + ") does not exist")
		result = False
	elif not os.path.isdir(os.path.join(os.getenv("ISE_EIFFEL"), "studio", "spec", os.getenv("ISE_PLATFORM"))):
		SystemLogger.error("Installed EiffelStudio version invalid (no directory found under " + os.path.join(os.getenv("ISE_EIFFEL"), "studio", "spec", os.getenv("ISE_PLATFORM")) + ")")
		result = False
	else:
		SystemLogger.debug("ISE_EIFFEL = " + os.getenv("ISE_EIFFEL"))
	# ISE_C_COMPILER
	if not "ISE_C_COMPILER" in os.environ:
		SystemLogger.error("Environment variable ISE_C_COMPILER not set")
		result = False
	elif os.getenv("ISE_C_COMPILER") != d_ise_c_compiler:
		SystemLogger.error("Value of environment variable ISE_C_COMPILER (" + os.getenv("ISE_C_COMPILER") + ") should be '" + d_ise_c_compiler + "'")
		result = False
	else:
		SystemLogger.debug("ISE_C_COMPILER = " + os.getenv("ISE_C_COMPILER"))
	# EIFFEL_SRC
	if not "EIFFEL_SRC" in os.environ:
		SystemLogger.error("Environment variable EIFFEL_SRC not set. EVE compilation not possible")
		result = False
	elif not os.path.isdir(os.getenv("EIFFEL_SRC")):
		SystemLogger.error("Path from environment variable EIFFEL_SRC (" + os.getenv("EIFFEL_SRC") + ") does not exist")
		result = False
	else:
		SystemLogger.debug("EIFFEL_SRC = " + os.getenv("EIFFEL_SRC"))
	# EWEASEL
	if not "EWEASEL" in os.environ:
		SystemLogger.error("Environment variable EWEASEL not set. EVE compilation not possible")
		result = False
	elif not os.path.isdir(os.getenv("EWEASEL")):
		SystemLogger.error("Path from environment variable EWEASEL (" + os.getenv("EWEASEL") + ") does not exist")
		result = False
	else:
		SystemLogger.debug("EWEASEL = " + os.getenv("EWEASEL"))
	# ISE_LIBRARY
	if not "ISE_LIBRARY" in os.environ:
		SystemLogger.error("Environment variable ISE_LIBRARY not set. EVE compilation not possible")
		result = False
	elif not os.path.isdir(os.getenv("ISE_LIBRARY")):
		SystemLogger.error("Path from environment variable ISE_LIBRARY (" + os.getenv("ISE_LIBRARY") + ") does not exist")
		result = False
	else:
		SystemLogger.debug("ISE_LIBRARY = " + os.getenv("ISE_LIBRARY"))
	# PATH: EiffelStudio, Boogie, Z3
	if not "PATH" in os.environ:
		SystemLogger.error("Environment variable PATH not set")
		result = False
	elif False: # TODO: check PATH contents
		result = False
	# final check
	if result:
		SystemLogger.success("Environment variables checked")
	return result