Ejemplo n.º 1
0
    def verify(self):
        """ Check whether the license file is integral; cnippet's version applies;
            and license has not expired.
        """

        secret = '$*we#j238@#WA!%'
        h = hashlib.sha1()
        h.update(secret[10:12])
        h.update(base64.b64encode(self.product))
        h.update(secret[1:4])
        h.update(self.version[0])
        h.update(secret[6:9])
        h.update(self.email)
        h.update(self.expiration)
        digest = h.hexdigest()

        # If the hash doesn't match, data has been corrupted.
        if self.key != digest:
            sys.exit(DiagnosticReporter.fatal(CORRUPTED_LICENSE_FILE))

        # Verify product version.
        if int(self.version[0]) != Version().major:
            sys.exit(
                DiagnosticReporter.fatal(INCOMPATIBLE_LICENSE_PRODUCT_VERSION))

        # Verify expiration.
        exp_date = datetime.datetime.strptime(self.expiration, '%d/%B/%Y')
        if datetime.datetime.today() > exp_date:
            sys.exit(DiagnosticReporter.fatal(LICENSE_EXPIRED))
Ejemplo n.º 2
0
 def fetch_versions_for_shot(self, m_shot_obj):
     ver_ret = []
     filters = [
         ['project', 'is', {'type' : 'Project', 'id' : int(self.g_shotgun_project_id)}],
         ['entity', 'is', {'type' : 'Shot', 'id' : int(m_shot_obj.g_dbid)}]
     ]
     fields = ['code', 'id', 'description', 'sg_first_frame', 'sg_last_frame', 'frame_count', 'sg_path_to_frames', 'sg_path_to_movie', 'entity', 'user', 'sg_task', 'sg_delivered', 'client_code', 'playlists', 'sg_path_to_matte_frames', 'sg_matte_ready_', 'sg_matte_delivered_']
     sg_vers = self.g_sg.find("Version", filters, fields)
     if not sg_vers:
         return ver_ret
     else:
         for sg_ver in sg_vers:
             local_artist = self.fetch_artist_from_id(int(sg_ver['user']['id']))
             tmp_ver = Version.Version(sg_ver['code'], sg_ver['id'], sg_ver['description'], sg_ver['sg_first_frame'], sg_ver['sg_last_frame'], sg_ver['frame_count'], sg_ver['sg_path_to_frames'], sg_ver['sg_path_to_movie'], m_shot_obj, local_artist, None)
             tmp_delivered = False
             if sg_ver['sg_delivered'] == 'True':
                 tmp_delivered = True
             tmp_ver.set_delivered(tmp_delivered)
             tmp_ver.set_client_code(sg_ver['client_code'])
             tmp_playlists = []
             for tmp_pl_struct in sg_ver['playlists']:
                 tmp_playlists.append(Playlist.Playlist(tmp_pl_struct['name'], [], tmp_pl_struct['id']))
             tmp_ver.set_playlists(tmp_playlists)
             if sg_ver['sg_path_to_matte_frames']:
                 tmp_ver.set_path_to_matte_frames(sg_ver['sg_path_to_matte_frames'])
             if sg_ver['sg_matte_ready_'] == 'True':
                 tmp_ver.set_matte_ready(True)
             if sg_ver['sg_matte_delivered_'] == 'True':
                 tmp_ver.set_matte_delivered(True)
             ver_ret.append(tmp_ver)
         return ver_ret
Ejemplo n.º 3
0
 def fetch_version_from_id(self, m_version_id):
     ver_ret = None
     filters = [
         ['project', 'is', {'type' : 'Project', 'id' : int(self.g_shotgun_project_id)}],
         ['id', 'is', m_version_id]
     ]
     fields = ['code', 'id', 'description', 'sg_first_frame', 'sg_last_frame', 'frame_count', 'sg_path_to_frames', 'sg_path_to_movie', 'entity', 'user', 'sg_task', 'sg_delivered', 'client_code', 'playlists', 'sg_path_to_matte_frames', 'sg_matte_ready_', 'sg_matte_delivered_']
     sg_ver = self.g_sg.find_one("Version", filters, fields)
     if not sg_ver:
         return ver_ret
     else:
         local_shot = self.fetch_shot_from_id(sg_ver['entity']['id'])
         local_task = self.fetch_task_from_id(int(sg_ver['sg_task']['id']), local_shot)
         local_artist = self.fetch_artist_from_id(int(sg_ver['user']['id']))
         ver_ret = Version.Version(sg_ver['code'], sg_ver['id'], sg_ver['description'], sg_ver['sg_first_frame'], sg_ver['sg_last_frame'], sg_ver['frame_count'], sg_ver['sg_path_to_frames'], sg_ver['sg_path_to_movie'], local_shot, local_artist, local_task)
         tmp_delivered = False
         if sg_ver['sg_delivered'] == 'True':
             tmp_delivered = True
         ver_ret.set_delivered(tmp_delivered)
         ver_ret.set_client_code(sg_ver['client_code'])
         tmp_playlists = []
         for tmp_pl_struct in sg_ver['playlists']:
             tmp_playlists.append(Playlist.Playlist(tmp_pl_struct['name'], [], tmp_pl_struct['id']))
         ver_ret.set_playlists(tmp_playlists)
         if sg_ver['sg_path_to_matte_frames']:
             ver_ret.set_path_to_matte_frames(sg_ver['sg_path_to_matte_frames'])
         if sg_ver['sg_matte_ready_'] == 'True':
             ver_ret.set_matte_ready(True)
         if sg_ver['sg_matte_delivered_'] == 'True':
             ver_ret.set_matte_delivered(True)
         return ver_ret
Ejemplo n.º 4
0
    def start(self):
        start = time.time()
        print("--> Starting build of the main code base")
        print("--> Build configuration " + Globals.build_target_ + " : " +
              Globals.build_parameters_)
        print("--> Operating System: " + Globals.operating_system_)

        self.cmake_compiler_ = Globals.cmake_compiler_  #[ 'Unix', 'MinGW' ][ Globals.operating_system_ == "windows" ]
        print("--> CMake Compiler: " + Globals.cmake_compiler_)

        # Check to see if the third party libraries have been built
        third_party_dir = "bin/" + Globals.operating_system_ + "_" + Globals.compiler_ + "/thirdparty"
        if not os.path.exists(third_party_dir):
            return Globals.PrintError(
                "Third party libraries have not been built. Please build these first with thirdparty argument"
            )

        ## Build Version.h
        version = Version()
        version.create_version_header()

        self.output_directory_ = "bin/" + Globals.operating_system_ + "_" + Globals.compiler_ + "/" + Globals.build_target_
        cmake_os_path = Globals.operating_system_ + "_" + Globals.compiler_

        if Globals.build_parameters_ != "":
            self.output_directory_ += "_" + Globals.build_parameters_

        if not os.path.exists(self.output_directory_):
            os.makedirs(self.output_directory_)
        print("--> Target output directory: " + self.output_directory_)

        os.chdir(self.output_directory_)

        if Globals.build_target_.upper(
        ) == "TEST":  # Handle new keyword TEST in CMake v3
            Globals.build_target_ = "TESTMODE"

        print('--> Preparing CMake command')
        build_string = 'cmake ' + self.cmake_compiler_ + ' -D' + Globals.build_target_.upper(
        ) + '=1'
        if Globals.build_parameters_ != "":
            build_string += ' -D' + Globals.build_parameters_.upper() + '=1'
        build_string += ' ../../..'

        print("--> CMake command: " + build_string)
        if os.system(build_string) != EX_OK:
            return Globals.PrintError(
                "Failed to execute cmake successfully to rebuild the make files"
            )

        print("--> Build main code base")
        if os.system(Globals.make_command_) != EX_OK:
            return Globals.PrintError(
                "Failed to build code base. Please see above for build error")

        elapsed = time.time() - start
        print('Compile finished in ' + str(round(elapsed, 2)) + ' seconds')
        return True
Ejemplo n.º 5
0
    def initializeFromJSONFiles(self):
        pth=os.path.join(self.where(),'init')
        nonjsonpath=os.path.join(self.where(),'init','not_json')
        shortlist=os.listdir(pth)#file list without path
        longlist=[os.path.join(pth,x) for x in shortlist]#file list with path
        longlist=filter(lambda x:os.path.isfile(x),longlist)
        for f in longlist:
            text=open(f,'r').read()#read in the text
            try:
                data=json.loads(text)#convert to json
            except:
                print '*'*10,'File %s has incorrect json.  Please correct!'%f
                continue

            self.loadFormattedText(nonjsonpath,data)
            
            if data['type']=='room':
                newobj=Room(**data)
            elif data['type']=='player':
                newobj=Player(**data)
            elif data['type']=='feature':
                newobj=Feature(**data)
            elif data['type']=='item':
                newobj=Item(**data)
            elif data['type']=='version':
                newobj=Version(**data)
            else:
                assert False #shouldn't happen
            name=newobj.name.lower()#insure that all names should be lower
            if hasattr(newobj,'adjacent_rooms'):
                for k,v in newobj.adjacent_rooms.items():
                    if not k==k.lower():print 'problem with adjacent roomf for %s'%name
            self.objects[name]=newobj#add the object to our dictionary
            newobj.otherObjects=self.objects#gives all objects access to other objects

        self.linkFeatures()
        self.linkItems()
        self.objects['version'].version=CURRENT_VERSION
Ejemplo n.º 6
0
import os
from setuptools import setup, find_packages
from [[appname]].commands.version import Version


def file_read(fname):
    return open(os.path.join(os.path.dirname(__file__), 'docs', fname)).read()

setup(
    name='[[appname]]',
    version=Version().get_version(),
    description='[[description]]',
    long_description=(file_read('README.rst')),
    url='[[url]]',
    license='[[license]]',
    author='[[author]]',
    author_email='[[email]]',
    platforms=['any'],
    #py_modules=['naked'],
    #scripts=['naked'],
    entry_points = {
        'console_scripts': [
            '[[appname]] = [[appname]].app:main'
        ],
    },
    packages=find_packages("lib"),
    package_dir={'': 'lib'},
    install_requires=['Naked', 'requests'],
    keywords='python,command line,system,application,framework,CLI,bootstrap',
    include_package_data=True,
    classifiers=[
Ejemplo n.º 7
0
def start():
	cli = CommandLineInterface()
	if not cli.parse():
  		cli.print_usage()
  		return False;
      
	print( "*************************************************************************")
	print( "*************************************************************************")
	
	Globals.buildtools_directory_ = os.getcwd()
	Globals.root_directory_ = os.path.realpath(Globals.buildtools_directory_ + "/../")
	Globals.boost_source_directory_ = os.path.realpath(Globals.root_directory_ + "/Boost")
	Globals.build_directory_ = os.path.realpath(Globals.root_directory_ + "/Build/" + Globals.operating_system_ )
	Globals.boost_directory_ = os.path.realpath(Globals.build_directory_ + "/Boost")
	
	print('--> Directory: ' + Globals.root_directory_)

	if not os.path.exists(Globals.build_directory_):
		if not os.path.exists(Globals.root_directory_ + "/Build"):
			os.mkdir(Globals.root_directory_ + "/Build")
		os.mkdir(Globals.build_directory_)
	
	print( "--> Starting " + Globals.build_target_ + " Build")
	build_target = Globals.build_target_
	if build_target == "release":
		code_builder = Release()
		return code_builder.start()
	elif build_target == "archive":	
		archive_builder = Archiver()
		return archive_builder.start()
	elif build_target == "boost":
		code_builder = Boost()
		return code_builder.start()
	elif build_target == "documentation":
		documentation_builder = Documentation()
		return documentation_builder.start()
	elif build_target == "unittests":
		unit_tests = UnitTests()
		return unit_tests.start()
	elif build_target == "examples":
		examples = Examples()
		return examples.start()
	elif build_target == "clean":
		cleaner = Cleaner()
		return cleaner.clean()
	elif build_target == "rlibrary":
		rlibrary = RLibrary()
		return rlibrary.start()
	elif build_target == "rinstall":
		Globals.install_r_library = "true"
		rlibrary = RLibrary()
		return rlibrary.start()
	elif build_target == "installer":
		installer = Installer()
		return installer.start()
#	elif build_target == "deb":
#		deb_builder = DebBuilder()
#		return deb_builder.start(build_parameters)
	elif build_target == "version":
		version = Version()
		return version.create_version_header()
	return False # Default return from this, we didn't find a run mode
Ejemplo n.º 8
0
    def start(self):
        start = time.time()
        print("--> Starting build of the main code base")
        print("--> Build configuration " + Globals.build_target_)
        print("--> Operating System: " + Globals.operating_system_)

        self.cmake_compiler_ = Globals.cmake_compiler_  #[ 'Unix', 'MinGW' ][ Globals.operating_system_ == "windows" ]
        print("--> CMake Compiler: " + Globals.cmake_compiler_)

        # Check to see if boost has been built
        folder = Globals.boost_directory_ + '/' + Globals.boost_version + '/bin.v2'
        if not os.path.exists(Globals.boost_directory_ + '/' +
                              Globals.boost_version + '/bin.v2'):
            return Globals.PrintError(
                "Boost has not been built. Please build these first with boost argument"
            )

        ## Build Version.h
        version = Version()
        version.create_version_header()

        print("--> Target output directory: " + Globals.build_directory_)

        os.chdir(Globals.build_directory_)

        print('--> Preparing CMake command')
        if Globals.operating_system_ == "windows":
            build_string = Globals.buildtools_directory_ + '/buildtools/windows/cmake/bin/cmake ' + self.cmake_compiler_ + ' -S ' + Globals.root_directory_ + '/BuildSystem/' + ' -B ' + Globals.build_directory_
        else:
            build_string = 'cmake ' + self.cmake_compiler_ + ' ' + Globals.root_directory_ + '/BuildSystem'
        print("--> CMake command: " + build_string)
        if os.system(build_string) != EX_OK:
            return Globals.PrintError(
                "Failed to execute cmake successfully to rebuild the make files"
            )

        print("--> Build main code base")
        if Globals.operating_system_ == "windows":
            if os.system("mingw32-make -j " + Globals.threads_) != EX_OK:
                return Globals.PrintError(
                    "Failed to build code base. Please see above for build error"
                )
            else:
                print('-->strip ' + Globals.build_directory_ + '/spm.exe')
                os.system('strip ' + Globals.build_directory_ + '/spm.exe')
                print('-->strip ' + Globals.build_directory_ +
                      '/spm_unittests.exe')
                os.system('strip ' + Globals.build_directory_ +
                          '/spm_unittests.exe')
                print('-->strip ' + Globals.build_directory_ +
                      '/spm_unoptimised.exe')
                os.system('strip ' + Globals.build_directory_ +
                          '/spm_unoptimised.exe')
        else:
            os.chdir(Globals.build_directory_)
            if os.system("make -j " + Globals.threads_) != EX_OK:
                return Globals.PrintError(
                    "Failed to build code base. Please see above for build error"
                )

        elapsed = time.time() - start
        print('Compile finished in ' + str(round(elapsed, 2)) + ' seconds')

        return True
Ejemplo n.º 9
0
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""System-specific parameters and functions."""

from '__go__/os' import Args
from '__go__/grumpy' import SysModules, MaxInt, Stdin as stdin, Stdout as stdout, Stderr as stderr  # pylint: disable=g-multiple-import
from '__go__/runtime' import (GOOS as platform, Version)
from '__go__/unicode' import MaxRune

argv = []
for arg in Args:
  argv.append(arg)

goversion = Version()
maxint = MaxInt
maxsize = maxint
maxunicode = MaxRune
modules = SysModules
py3kwarning = False
warnoptions = []
# TODO: Support actual byteorder
byteorder = 'little'
version = '2.7.13'

class _Flags(object):
  """Container class for sys.flags."""
  debug = 0
  py3k_warning = 0
  division_warning = 0
Ejemplo n.º 10
0
def start():
	cli = CommandLineInterface()
	if not cli.parse():
  		cli.print_usage()
  		return False
      
	print("*************************************************************************")
	print("*************************************************************************")
	print(f"--> Starting {Globals.build_target_} Build")
	build_target = Globals.build_target_
	build_parameters = Globals.build_parameters_

	# Build Version
	version = Version()
	version.create_version_header()

	if build_target == "version":
		version = Version()
		version.create_version_header(display_output=True)
	elif build_target in Globals.allowed_build_types_:
		code_builder = MainCode()
		return code_builder.start()
	elif build_target == "library":
		if not build_parameters in Globals.allowed_library_parameters_:
			return Globals.PrintError(f"Library build parameter {build_parameters} is not valid")
		print("--> Starting " + Globals.build_target_ + " Build")
		code_builder = MainCode()
		return code_builder.start(build_library=True)			
	elif build_target == "frontend":
		print("--> Starting " + Globals.build_target_ + " Build")
		code_builder = FrontEnd()
		return code_builder.start()
	elif build_target == "archive":	
		archive_builder = Archiver()
		return archive_builder.start(build_parameters)
	elif build_target == "thirdparty" or build_target == "thirdpartylean":
		code_builder = ThirdPartyLibraries()
		return code_builder.start()
	elif build_target == "documentation":
		documentation_builder = Documentation()
		return documentation_builder.start()
	elif build_target == "modelrunner":
		model_runner = ModelRunner()
		return model_runner.start()
	elif build_target == "unittests":
		unit_tests = UnitTests()
		return unit_tests.start()	
	elif build_target == "clean":
		cleaner = Cleaner()
		return cleaner.clean()	
	elif build_target == "cleancache":
		cleaner = Cleaner()
		return cleaner.clean_cache()
	elif build_target == "clean_all":
		cleaner = Cleaner()
		return cleaner.clean_all()
	elif build_target == "rlibrary":
		rlibrary = Rlibrary()
		return rlibrary.start()
	elif build_target == "installer":
		if Globals.operating_system_ == 'linux':
			return Globals.PrintError('Building Windows installer under linux is not supported')		
		installer = Installer()
		return installer.start()
	elif build_target == "deb":
		if Globals.operating_system_ == 'windows':
			return Globals.PrintError('Building linux .deb under Windows is not supported')
		deb_builder = DebBuilder()
		return deb_builder.start(build_parameters)
	return False # Default return from this, we didn't find a run mode
Ejemplo n.º 11
0
def _parse_input():
    """ Parse input, identify options, host compiler and its command """

    parser = argparse.ArgumentParser(
        add_help=False,
        formatter_class=argparse.RawDescriptionHelpFormatter,
        description='\tcnippet - the compiler for C snippets\n',
        epilog='examples:\n'
        '  $cnip gcc file.c\n'
        '  $cnip gcc file.c -o exe\n'
        '  $cnip clang -c file.c\n')

    version_str = '%s' % Version()
    copyright_str = 'Copyright 2017 Leandro T. C. Melo'

    parser.add_argument('-v',
                        '--version',
                        action='version',
                        version='%(prog)s ' + version_str + '\n' +
                        copyright_str,
                        help="Show program's version number and exit.")

    parser.add_argument('-h',
                        '--help',
                        action='help',
                        default=argparse.SUPPRESS,
                        help='Show this help message and exit.')

    parser.add_argument(
        '--no-heuristic',
        action='store_true',
        help='Disable heuristics on unresolved syntax ambiguities.')

    parser.add_argument('--no-typedef',
                        action='store_true',
                        help='Forbid typedef and struct/union declarations.')

    parser.add_argument('--no-stdlib',
                        action='store_true',
                        help="Don't attempt to match stdlib names.")

    parser.add_argument('-f',
                        '--non-commercial-use',
                        action='store_true',
                        help="Specify non-commercial use of cnippet.")

    parser.add_argument('-t',
                        '--trace',
                        action='append',
                        help='Enable (component) tracing.')

    parser.add_argument('--trace-level',
                        choices=['info', 'detail'],
                        default='info',
                        help='Tracing level.')

    parser.add_argument('CC', help='Host C compiler.')

    parser.add_argument('command',
                        nargs=argparse.REMAINDER,
                        help='Command forwarded to the host C compiler.')

    # Hidden arguments.
    parser.add_argument('-d',
                        '--dev',
                        action='store_true',
                        help=argparse.SUPPRESS)

    return parser.parse_args()