LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Python Node - Max length of password

    Employee
    Posted 01-30-2017 13:12

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: jpstory

    Hi

    I created a node that removes the read & write password off Excel files. (Basically, the node just launches Excel behind the screen and opens up the file via Excel and removes the password. The password is provided to the node as an input parameter)

    It's been working fine until lately it failed on a file that has password of length of 16 characters. The file has the same password for both Read and Write access, the password is in the same pattern as AbcdEfghijk12345.
    But if I set the password to be 15-character long AbcdEfghijk1234 on purpose and then run the node, it works just fine.

    I wonder if it's becasue I chose the wrong data type when set up the paramter, so I tried Text, String and Password but none of them worked.

    Here's the code:

    import braininfo
    import os, sys
    import win32com.client
    
    def setup(brainNodeControlObj, BrainNodeClass):
    	class BrainNode(BrainNodeClass):
    		
    		def finalize(self, val):
    			super(BrainNode, self).finalize(val)
    			#Actions to execute when the class finishes its task
    			self.xcl.Quit()
    			self.xcl = None
    			del self.xcl
    			
    		def initialize(self):
    			super(BrainNode, self).initialize()
    			metadata = self.newMetadata()
    			metadata.append("FileName","String")
    			metadata.append("OpenPassword","String")
    			metadata.append("WritePassword","String")
    			self.outputs[0].metadata = metadata
    			
    			metadataExcpt = self.newMetadata()
    			metadataExcpt.append("FileName","String")
    			metadataExcpt.append("OpenPassword Tried","String")
    			metadataExcpt.append("WritePassword Tried","String")
    			self.outputs[1].metadata = metadataExcpt
    			
    			#Load Parameters
    			self.OpenPsWd = self.properties.getString("ls.brain.node.decrypt.openpassword")
    			self.WritePsWd = self.properties.getString("ls.brain.node.decrypt.writepassword")
    		def pump(self, quant):
    			self.xcl = win32com.client.Dispatch('Excel.Application')
    			while quant.permitsRunning(self):
    				inRec = self.inputs[0].read()
    				if not inRec:
    					return False
    				filename = inRec["FileName"]
    				
    				#try:
    				self.Decrypt(filename)
    				outRec = self.outputs[0].newRecord()
    				outRec["FileName"] = filename
    				outRec["OpenPassword"] = self.OpenPsWd
    				outRec["WritePassword"] = self.WritePsWd
    				self.outputs[0].write(outRec)
    				#except:
    					#outRec = self.outputs[1].newRecord()
    					#outRec["FileName"] = filename
    					#outRec["OpenPassword Tried"] = self.OpenPsWd
    					#outRec["WritePassword Tried"] = self.OpenPsWd
    					#self.outputs[1].write(outRec)
    
    			return True  
    			#self.xcl.Quit()
    			
    		def Decrypt(self,filename):
    			#Open(Filename As String,[UpdateLink],[ReadOnly],[Format],[WriteResPassword],[IgnoreReadOnlyRecommended],[Origin],
    			#[Delimiter],[Editable],[Notify],[Converter],[AddToMru],[CorruptLoad])
    			wb = self.xcl.workbooks.open(filename, False, False, None, str(self.OpenPsWd), str(self.WritePsWd))
    			wb.Password = ""
    			wb.WritePassword = ""
    			self.xcl.DisplayAlerts = False
    			self.xcl.ScreenUpdating = False
    			wb.Save()
    			wb.Close()
    	return BrainNode


  • 2.  RE: Python Node - Max length of password

    Employee
    Posted 01-30-2017 13:22

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    That could be a limitation of the win32com library.
    self.xcl = win32com.client.Dispatch('Excel.Application')


  • 3.  RE: Python Node - Max length of password

    Employee
    Posted 01-30-2017 14:55

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: jpstory

    Hi stonysmith

    Are there any other standard Python modules that I can use as alternative other than Win32Com to remove Excel password? Or do I have to install additional module into Python to make it work?

    Or you perhaps have a better way to deal with the issue? I noted that others have long requested/inquired about when a LavaStorm Decrypt Node can be developed.


  • 4.  RE: Python Node - Max length of password

    Employee
    Posted 02-01-2017 15:21

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    I'm not aware of another library, you'd have do some to research. You should find that we already have the "xlrd" library loaded so that you could use it.. but it doesn't support passwords. Have you checked the win32com documentation?

    A general purpose "decrypt" node is not likely to help you with Excel. If we did build such a node, it would decrpyt/encrypt an entire file (externally) and would not deal with the internals inside of an Excel sheet.


  • 5.  RE: Python Node - Max length of password

    Employee
    Posted 02-02-2017 11:00

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: jpstory

    I have been researching on win32com but did not come across any specification related to max password length.

    Sorry as I did not provide clarificaiton on what type of password I am trying to remove.
    It's not Excel sheet protection password, rather it's the password that prompts at file openning.

    Hopefully there will be such a node built soon as spreadsheets are still common media for data storage and transition for layman today.


  • 6.  RE: Python Node - Max length of password

    Employee
    Posted 02-03-2017 02:28

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: awilliams1024

    Hi,

    Another way to enable Lavastorm to access password protected Excel files could be to use a node based on the add-on Open Source R node. However this approach has a number of dependencies so may not be suitable for everyone.

    The attached dataflow provides a node that will operate on Windows machines only (or where the specified R server is running on a Windows machine) as it leverages the Microsoft Excel application during its operation.
    The node uses the Open Source 'RDCOMClient' CRAN package. Due to licensing restrictions, this package must be downloaded separately if it is not already installed on the machine. However, as a convenience, the node will download and install this package provided you consent to this operation by accepting the licence agreement on the node's License tab.

    The node requires access to a running R server. By default, the node will try to connect to an Rserve instance on the local machine but this can be configured on the node's Connection tab. The machine hosting the R server needs to have Excel installed.

    The node imports data from the specified sheet within the Excel file (or the first sheet if the sheet index is not specified).

    R_Node_Read_Excel_Sheet_v1.0.brg


    The R node installer for Lavastorm 6.1.x is available from the Lavastorm website and can be found here:

    http://www.lavastorm.com/current-rel...orm-libraries/


    Download and install the version of the R Analytics installer that matches the architecture of the Lavastorm application you have installed (32-bit / 64-bit).

    See the release notes for installation and set-up information, and how to start Rserve.