def release(self, build_info): archive = self._archive_dir( build_info['category'], build_info['pkg_name'], build_info['version'], build_info['arch'] ) if not os.path.exists(archive): return legacy = os.path.join( self.cfg['release']['archive_dir'], build_info['category'], build_info['pkg_name'], build_info['version'], build_info['arch'] ) compat = os.path.dirname(legacy) self._makedirs(compat, exist_ok=True) retry = True while True: try: os.symlink(os.path.relpath(archive, compat), legacy) break except OSError as e: if retry and e.errno == errno.EEXIST: if os.path.islink(legacy) and os.path.realpath(legacy) == os.path.realpath(archive): break bak = '%s.bak%s' % (legacy, int(time.time())) warn('Unexpected folder found at %s: it will be renamed %s' % (legacy, bak), output=self.log_fd) shutil.move(legacy, bak) retry = False else: raise
def warn(msg): # six.print_(time.strftime("%Y-%m-%d %H:%M:%S"), msg) xutils.warn("INIT", msg)