Example #1
0
 def getSetupFileInfo(self):
     files = system.list_all_files_cwd()
     if len(files) > 0:
         setupfile_exists = False
         for a_file in files:
             if 'naked.yaml' == a_file.lower(): # accepts any permutation of upper/lower case 'naked.yaml'
                 print("Detected a Naked project YAML setup file (" + a_file + ").")
                 setupfile_exists = True
                 fr = nfile.FileReader(a_file)
                 the_yaml = fr.read_utf8()
                 self.parseYaml(the_yaml)
         if setupfile_exists:
             if self.confirmData():
                 return self.data
             else:
                 print("Aborted the project build.")
                 if python.is_py2():
                     response = raw_input("Would you like to modify this information? (y/n) ")
                 else:
                     response = input("Would you like to modify this information? (y/n) ")
                 if response in ['y', 'Y', 'Yes', 'YES', 'yes']:
                     self.displayed_info_flag = 1
                     self.data.app_name = None
                     return self.getUserInfo() # return the result from the getUserInfo command to the calling method
                 else:
                     sys.exit(0)
         else:
             return self.getUserInfo() # there are files but no setup file, use the manual entry method
     else:
         return self.getUserInfo() # there are no files in the directory, use the manual entry method
 def getUserInfo(self):
     if not self.displayed_info_flag:
         print("We need some information to create your project.")
         self.displayed_info_flag = 1
     # If no project name, then query for it because this is mandatory
     if self.data.app_name == None:
         if python.is_py2:
             response = raw_input(
                 "Please enter your application name (q=quit): ")
         else:
             response = input(
                 "Please enter your application name (q=quit): ")
         if len(response) > 0:
             if response == "q":
                 print("Aborted project build.")
                 sys.exit(0)  # user requested quit
             else:
                 if len(response.split()) > 1:  # if more than one word
                     print(
                         "The application name must be a single word.  Please try again."
                     )
                     self.getUserInfo()
                 else:
                     self.data.app_name = response
         else:
             print(
                 "The Naked project will not build without an application name.  Please try again."
             )
             return self.getUserInfo()
     # if project name already set, then obtain the other optional information
     if python.is_py2():
         self.data.developer = raw_input(
             "Enter the licensing developer or organization (q=quit): ")
         if self.data.developer == "q":
             print("Aborted the project build.")
             sys.exit(0)
         self.data.license = raw_input(
             "Enter the license type (or leave blank, q=quit): ")
         if self.data.license == "q":
             print("Aborted the project build.")
             sys.exit(0)
     else:
         self.data.developer = input(
             "Enter the licensing developer or organization: ")
         if self.data.developer == "q":
             print("Aborted the project build.")
             sys.exit(0)
         self.data.license = input(
             "Enter the license type (or leave blank): ")
         if self.data.license == "q":
             print("Aborted the project build.")
             sys.exit(0)
     if self.confirmData():
         return self.data
     else:
         print("Let's try again...")
         return self.getUserInfo()  # try again
Example #3
0
 def test_ascii_templatetext_is_unicode(self):
     temp = DoxxTemplate(self.ascii_template)
     temp.load_data()
     temp.split_data()
     temp.parse_template_for_errors()
     temp.parse_template_text()
     
     if is_py2():
         self.assertEqual(unicode, type(temp.text))
     else:
         self.assertEqual(str, type(temp.text))
Example #4
0
    def setUp(self):
        self.truth_pyversion = (sys.version_info[0], sys.version_info[1], sys.version_info[2])
        self.truth_pymajor = sys.version_info[0]
        self.truth_pyminor = sys.version_info[1]
        self.truth_pypatch = sys.version_info[2]
        self.truth_is_py2 = (self.truth_pymajor == (2))
        self.truth_is_py3 = (self.truth_pymajor == (3))

        self.test_pyversion = py_version()
        self.test_pymajor = py_major_version()
        self.test_pyminor = py_minor_version()
        self.test_pypatch = py_patch_version()
        self.test_is_py2 = is_py2()
        self.test_is_py3 = is_py3()
Example #5
0
    def setUp(self):
        self.truth_pyversion = (sys.version_info[0], sys.version_info[1],
                                sys.version_info[2])
        self.truth_pymajor = sys.version_info[0]
        self.truth_pyminor = sys.version_info[1]
        self.truth_pypatch = sys.version_info[2]
        self.truth_is_py2 = (self.truth_pymajor == (2))
        self.truth_is_py3 = (self.truth_pymajor == (3))

        self.test_pyversion = py_version()
        self.test_pymajor = py_major_version()
        self.test_pyminor = py_minor_version()
        self.test_pypatch = py_patch_version()
        self.test_is_py2 = is_py2()
        self.test_is_py3 = is_py3()
Example #6
0
 def getUserInfo(self):
     if not self.displayed_info_flag:
         print("We need some information to create your project.")
         self.displayed_info_flag = 1
     # If no project name, then query for it because this is mandatory
     if self.data.app_name == None:
         if python.is_py2:
             response = raw_input("Please enter your application name (q=quit): ")
         else:
             response = input("Please enter your application name (q=quit): ")
         if len(response) > 0:
             if response == "q":
                 print("Aborted project build.")
                 sys.exit(0) # user requested quit
             else:
                 if len(response.split()) > 1: # if more than one word
                     print("The application name must be a single word.  Please try again.")
                     self.getUserInfo()
                 else:
                     self.data.app_name = response
         else:
             print("The Naked project will not build without an application name.  Please try again.")
             return self.getUserInfo()
     # if project name already set, then obtain the other optional information
     if python.is_py2():
         self.data.developer = raw_input("Enter the licensing developer or organization (q=quit): ")
         if self.data.developer == "q":
             print("Aborted the project build.")
             sys.exit(0)
         self.data.license = raw_input("Enter the license type (or leave blank, q=quit): ")
         if self.data.license == "q":
             print("Aborted the project build.")
             sys.exit(0)
     else:
         self.data.developer = input("Enter the licensing developer or organization: ")
         if self.data.developer == "q":
             print("Aborted the project build.")
             sys.exit(0)
         self.data.license = input("Enter the license type (or leave blank): ")
         if self.data.license == "q":
             print("Aborted the project build.")
             sys.exit(0)
     if self.confirmData():
         return self.data
     else:
         print("Let's try again...")
         return self.getUserInfo() # try again
Example #7
0
    def confirmData(self):
        templ_str = getHeaderTemplate()
        template = ink.Template(templ_str)
        renderer = ink.Renderer(template, {'app_name': self.data.app_name, 'developer': self.data.developer, 'license': self.data.license, 'year': self.data.year})
        display_header = renderer.render()
        print("\nPlease confirm the information below:")
        print(display_header)

        if python.is_py2():
            response = raw_input("Is this correct? (y/n) ")
        else:
            response = input("Is this correct? (y/n) ")

        if response in ['y', 'Y', 'yes', 'YES']:
            return True
        else:
            self.data.app_name = None
            return False
Example #8
0
	def __init__(self):
		now = datetime.datetime.now()
		self.py2 = py.is_py2() #truth test Python 2 interpreter
		self.py3 = py.is_py3() #truth test Python 3 interpreter
		self.py_major = py.py_major_version() #Python major version
		self.py_minor = py.py_minor_version() #Python minor version
		self.py_patch = py.py_patch_version() #Python patch version
		self.os = sys.platform #user operating system
		self.cwd = cwd() #current (present) working directory
		self.parent_dir = os.pardir
		self.default_path = os.defpath
		self.user_path = os.path.expanduser("~")
		self.string_encoding = sys.getdefaultencoding()
		self.file_encoding = sys.getfilesystemencoding()
		self.hour = now.hour
		self.min = now.minute
		self.year = now.year
		self.day = now.day
		self.month = now.month
		self.second = now.second
 def __init__(self):
     now = datetime.datetime.now()
     self.py2 = py.is_py2()  #truth test Python 2 interpreter
     self.py3 = py.is_py3()  #truth test Python 3 interpreter
     self.py_major = py.py_major_version()  #Python major version
     self.py_minor = py.py_minor_version()  #Python minor version
     self.py_patch = py.py_patch_version()  #Python patch version
     self.os = sys.platform  #user operating system
     self.cwd = cwd()  #current (present) working directory
     self.parent_dir = os.pardir
     self.default_path = os.defpath
     self.user_path = os.path.expanduser("~")
     self.string_encoding = sys.getdefaultencoding()
     self.file_encoding = sys.getfilesystemencoding()
     self.hour = now.hour
     self.min = now.minute
     self.year = now.year
     self.day = now.day
     self.month = now.month
     self.second = now.second
 def getSetupFileInfo(self):
     files = system.list_all_files_cwd()
     if len(files) > 0:
         setupfile_exists = False
         for a_file in files:
             if 'naked.yaml' == a_file.lower(
             ):  # accepts any permutation of upper/lower case 'naked.yaml'
                 print("Detected a Naked project YAML setup file (" +
                       a_file + ").")
                 setupfile_exists = True
                 fr = nfile.FileReader(a_file)
                 the_yaml = fr.read_utf8()
                 self.parseYaml(the_yaml)
         if setupfile_exists:
             if self.confirmData():
                 return self.data
             else:
                 print("Aborted the project build.")
                 if python.is_py2():
                     response = raw_input(
                         "Would you like to modify this information? (y/n) "
                     )
                 else:
                     response = input(
                         "Would you like to modify this information? (y/n) "
                     )
                 if response in ['y', 'Y', 'Yes', 'YES', 'yes']:
                     self.displayed_info_flag = 1
                     self.data.app_name = None
                     return self.getUserInfo(
                     )  # return the result from the getUserInfo command to the calling method
                 else:
                     sys.exit(0)
         else:
             return self.getUserInfo(
             )  # there are files but no setup file, use the manual entry method
     else:
         return self.getUserInfo(
         )  # there are no files in the directory, use the manual entry method
    def confirmData(self):
        templ_str = getHeaderTemplate()
        template = ink.Template(templ_str)
        renderer = ink.Renderer(
            template, {
                'app_name': self.data.app_name,
                'developer': self.data.developer,
                'license': self.data.license,
                'year': self.data.year
            })
        display_header = renderer.render()
        print("\nPlease confirm the information below:")
        print(display_header)

        if python.is_py2():
            response = raw_input("Is this correct? (y/n) ")
        else:
            response = input("Is this correct? (y/n) ")

        if response in ['y', 'Y', 'yes', 'YES']:
            return True
        else:
            self.data.app_name = None
            return False
Example #12
0
File: build.py Project: tstyle/doxx
import sys
import os
from multiprocessing import Process, Lock

from Naked.toolshed.file import FileWriter
from Naked.toolshed.system import cwd, dir_exists, file_exists, make_dirs, make_path, stderr, stdout
from Naked.toolshed.python import is_py2

from doxx.datatypes.template import DoxxTemplate, RemoteDoxxTemplate
from doxx.datatypes.key import DoxxKey
from doxx.commands.pull import run_pull, is_url
from doxx.commands.unpack import unpack_run

# need a different template for Python 2 & 3
if is_py2():    
    from doxx.renderer.inkpy2 import Template as InkTemplate
    from doxx.renderer.inkpy2 import Renderer as InkRenderer
else:
    from doxx.renderer.inkpy3 import Template as InkTemplate
    from doxx.renderer.inkpy3 import Renderer as InkRenderer


def multi_process_build(key, key_path):
    processes = []       # list of spawned processes
    iolock = Lock()      # file read / write lock
    outputlock = Lock()  # stdout / stderr writes lock
    
    # ## SINGLE PROCESS
    # for template in key.meta_data['templates']:
        # b = Builder()