Just a little more indirection...



  • This is part of a python script, which calls Maya's MEL to set a Maya expression (which has slightly different syntax from MEL) which calls some python in the process of making some text which ultimately gets stuck into a MentalRay .mi file, which includes another mi file generated by a third party tool.  It's my own fault, and for some reason, I'm convinced that this is the most practical solution.  And, it's actually a lot clearer now than it was previously.  (It was very nearly a single representative line...)

     

    mel.eval( """createNode expression -shared -n "MassiveMentalRayInclusionExpression"; """)
    mel.eval( """    setAttr -k on ".nds"; """)
        
    exprtext = """
    string $fr = frame;
    string $time = python ("'%04d' % "+$fr) ;
    string $stringData = "$include "/jobs/rnd_massive/build/build_sequence/maya/massive/phenomTest/mi/a" + $time + ".mi"";
    setAttr "mentalrayText_SceneIncludeText.tex" -type "string" $stringData;
    """

    exprtext = exprtext.replace("\", "\\")
    exprtext = exprtext.replace(""", "\"")
    exprtext = exprtext.replace("\n", "\n")
        
    mel.eval( 'setAttr ".ixp" -type "string" "' + exprtext + '";')



  •  That reminds me of sending LDAP query strings to SQL Server to get data from Active Directory. I still have eye strain from counting all the quotation marks


  • Discourse touched me in a no-no place

    @token_woman said:

     That reminds me of sending LDAP query strings to SQL Server to get data from Active Directory. I still have eye strain from counting all the quotation marks

    I was writing something that did that - but got pissed off at it (IIRC I could get neither an SP nor a function to take a parameter and put it into an LDAP query - it was either specify the entire query or nothing) and just added a service on the appserver that took a periodic dump of the relevant AD data and shoved it into a table on the SQL server. Much cleaner, much less failure-prone, each query is quicker, and thank the sweet baby jesus it's actually fully functional.Sure, somebody's directory data might be momentarily out of date, but names and email addresses do not change often.



  • @Weng said:

    I was writing something that did that - but got pissed off at it (IIRC I could get neither an SP nor a function to take a parameter and put it into an LDAP query - it was either specify the entire query or nothing) and just added a service on the appserver that took a periodic dump of the relevant AD data and shoved it into a table on the SQL server. Much cleaner, much less failure-prone, each query is quicker, and thank the sweet baby jesus it's actually fully functional.Sure, somebody's directory data might be momentarily out of date, but names and email addresses do not change often.
     

     I think I managed to do the parameter thing by using dynamic SQL. It was truly hideous. These days I try to avoid that sort of text-twiddling and backslash-mongering as much as I can

     

     



  • @Weng said:

    @token_woman said:

     That reminds me of sending LDAP query strings to SQL Server to get data from Active Directory. I still have eye strain from counting all the quotation marks

    I was writing something that did that - but got pissed off at it (IIRC I could get neither an SP nor a function to take a parameter and put it into an LDAP query - it was either specify the entire query or nothing) and just added a service on the appserver that took a periodic dump of the relevant AD data and shoved it into a table on the SQL server. Much cleaner, much less failure-prone, each query is quicker, and thank the sweet baby jesus it's actually fully functional.Sure, somebody's directory data might be momentarily out of date, but names and email addresses do not change often.

    I'm confused.  Of course, you probably knew that already, but...  I thought AD used MS SQL Server as its back end, so the AD data would already be in one or more tables on the SQL server?

    Disclaimer: I don't know much about AD.  I just know I've been told it had a number of fields, such as 'cn', as fundamentally single-valued fields, and this couldn't be changed by a schema update, because they're specifically coded into AD as defined SQL Server columns.  One can make any custom fields multi-valued at whim, but one cannot change the attributes that are defined in the base product.  I haven't verified these claims, but they came from someone who is Microsoft Certified, administers an AD cluster, and is also pro-Microsoft.  As such, I think he should know, and doubt he's likely to trash the product unfairly.


  • Discourse touched me in a no-no place

    @tgape said:

    I'm confused.  Of course, you probably knew that already, but...  I thought AD used MS SQL Server as its back end, so the AD data would already be in one or more tables on the SQL server?

    If it does, it's not exposed and not directly addressable in any way whatsoever - the only way a normal SQL Server can talk to it is via LDAP. If it is storing things in SQL-compatible files on the backend, I doubt it's running the full heavyweight SQL Server, either - because the load an AD server puts on a system is miniscule compared to a SQL Server.

    Furthermore, I've learned to severely distrust AD admins (ESPECIALLY certified ones) when it comes to anything except the practical side of AD - they're especially confused by other Microsoft products.



  • @wrosecrans said:

    t's my own fault, and for some reason, I'm convinced that this is the most practical solution.

    I don't understand why you're using a python call to pad the frame number, doing this in MEL is fairly straightforward.

    The following javascript function could easily be converted to a MEL proc.

    Likewise, you should be able to include all your MEL in a single set of triple quotes.



  • @tgape said:

    I'm confused.  Of course, you probably knew that already, but...  I thought AD used MS SQL Server as its back end, so the AD data would already be in one or more tables on the SQL server?

    No. Active Directory's database engine is the Extensible Storage Engine which is based on the Jet database. It's got more in common with Exchange than with SQL.

     http://en.wikipedia.org/wiki/Extensible_Storage_Engine

    As already mentioned, you access the data via LDAP Queries. As I recall, even Microsoft SQL-based products such as Sharepoint and SCCM that pull data from Active Directory sync up every few hours or so, similiar to Weng's proposed solution, instead of trying to execute live queries against AD.



  • @cdosrun said:

    As I recall, even Microsoft SQL-based products such as Sharepoint and SCCM that pull data from Active Directory sync up every few hours or so, similiar to Weng's proposed solution, instead of trying to execute live queries against AD.
     

    Reading this, I came up against my own lack of experience In The Industry; such non-integration between core M$ products still provokes a negative reaction in my brain. 



  • I complain about my last job (IT at a collection agency), but I did kinda get to do some cool things at it, sometimes meshing together a bunch of systems

    Let's see, #1)

    A Call from my cell phone in the morning ->

    A Cisco Callmanager VoIP system ->

    A Non-message left in my Cisco Unity Voicemail Box ->

    That emailed the voice messages to my Exchange Mail box ->

    That went into Outlook with the subject "Message from 604-555-1234" ->

    Which triggered an outlook rule ->

    That fired a WSH script on my computer ->

    That performed 35 minutes of manual routine actions on an AS/400 system in about 40 seconds of script time.

    And #2:

    Pressing a shortcut key in the AS/400 Terminal session program (Client Access) ->

    That fired a terminal session program Macro ->

    That called a local WSH Script ->

    That performed a a screen scrape of a phone number from the terminal session and fired a non-graphical Ajax request to an intranet webserver ->

    That grabbed the telephone extension of REMOTE_USER via Active Directory lookup ->

    Then looked up the IP Address of the IP Phone extension from Callmanager ->

    That fired the internal webserver of the IP Phone ->

    To dial the number scraped from the Terminal session from the users phone.



  • I wrote a fade-anything in javascript where I put a style attribute with a quoted background path in HTML in a string in javascript which is constructed by ASP in a string.



  • @Soviut said:

    I don't understand why you're using a python call to pad the frame number, doing this in MEL is fairly straightforward.

    The following javascript function could easily be converted to a MEL proc.

    Likewise, you should be able to include all your MEL in a single set of triple quotes.

     

     

    It is possible to the all the MEL in a single block.  But, the whole block that is in "exprtext" is a parameter to "setAttr," so it needs to be on a single line.  \n inside triple quotes gets treated as an actual newline, so I need to multiply-escape everythng inside that expression, which makes for a monster of a single line.  By making the expression text it's own string, I can doctor it with a few lines of automatic escaping to collapse it into the single line more reliably than doing it by hand.  (especially since that went through many variations, so I would have been doing it a lot by hand during testing and tweaking.

     

    As for why use python for padding inside the expression...  Meh, it seemed like a good idea at the time, which I was just figuring out how to setup the expression in the normal way, before it all got wrapped up in a script.  I googled for what the best way to pad zeroes in MEL was, and whatever hit I read suggested the python way, which suited me fine because I know python a heck of a lot better than MEL.  (When you have a hammer, every problem can be declared topologically equivalent to a nail...)    :)   Most importantly, the posted snippet has evolved into part of a script that does what I needed it to do.  In any event, I'm doing far uglier things on this project.  Next up is string processing in a mental ray shader.  (ha ha, yes really)


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.