Author Topic: Exporting Device Templates - ignoring sqlCVS for the moment  (Read 9405 times)

posde

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2934
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #15 on: October 11, 2008, 12:29:51 pm »
eran,

yes, you can't take a template out, that is in sqlCVS. Reason is: The exporter looks for the psc_mod date. If it is 0 it does not get exported.

The reason behind the exporter is, that you can save your own av device templates, and don't have to relearn your remotes due to a needed reinstall of lmce. Also, it allows for people to exchange the av device profiles with each other.

rgds
Oliver

eran

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #16 on: October 11, 2008, 12:34:30 pm »
So you can also make a generic template exporter that will go on all template
and take out only the one that you created...

and in this way you can make a routine to export every template for back up...
with out the need to remember what template you add...

posde

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2934
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #17 on: October 12, 2008, 11:26:54 am »
Theoretically, this is possible, but I think it would defeat the purpose.

But feel free to do such an enhancement to the script ;)

rgds
Oliver

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 884
  • Living with LMCE
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #18 on: January 08, 2009, 10:10:18 am »
Hi,

I also tried template exporter (thanks for effort), but for me it doesn't work cause my templates were contributed through sqlcvs. Was it meant to do so ?

In my case I have several templates I've contributed to older Mantis system and since it's unclear what will happen with those contributions, I would like now to backup them into sql files but it seems that Exporter as it is won't do this?

Has anyone done any enhancements to this script ?

Thanks in advance,

regards,

Bulek.
Thanks in advance,

regards,

Bulek.

chriss

  • Veteran
  • ***
  • Posts: 140
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #19 on: January 08, 2009, 10:46:50 am »
In my case I have several templates I've contributed to older Mantis system and since it's unclear what will happen with those contributions

bulek,

I'm not part of the dev team myself so I can't say for sure, but in the Trac Wiki the devs wrote
Quote from: http://svn.linuxmce.org
Trac can import the Mantis tickets automatically, but we decided this is not a good idea since we will want to review each ticket from Mantis.
so I think that the tickets are not lost.

You can check for your contributions on http://sqlcvs.linuxmce.org/sqlcvs/, too and if I remember correctly, the mantis system still exists and you can apply for access to the old mantis system.

just my 2c
/chriss

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 884
  • Living with LMCE
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #20 on: January 08, 2009, 11:33:20 am »
In my case I have several templates I've contributed to older Mantis system and since it's unclear what will happen with those contributions

bulek,

I'm not part of the dev team myself so I can't say for sure, but in the Trac Wiki the devs wrote
Quote from: http://svn.linuxmce.org
Trac can import the Mantis tickets automatically, but we decided this is not a good idea since we will want to review each ticket from Mantis.
so I think that the tickets are not lost.

You can check for your contributions on http://sqlcvs.linuxmce.org/sqlcvs/, too and if I remember correctly, the mantis system still exists and you can apply for access to the old mantis system.

just my 2c
/chriss
Hi,

thanks for info. I see them from Mantis #4287 to Mantis #4292. There is a hope....

Regards,

Bulek
Thanks in advance,

regards,

Bulek.

alx9r

  • Guru
  • ****
  • Posts: 187
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #21 on: April 12, 2009, 06:21:03 am »
posde,
Thanks for making this available.  This script seems like an excellent stopgap solution to sharing device templates until the sqlCVS method is working better. 

There seems to be a bug in the script.  If you export, then import a device template, all words in the ruby code beginning with $ are deleted.  Unfortunately ruby uses lots of $ characters so this causes a lot of corruption.

for example:
Code: [Select]
def readLine()
$line=String.new
$index=0

cod=conn_.Recv(1, $waitTime)
$line+=cod

beforeTime = Time.now

becomes
Code: [Select]
def readLine()
   =String.new
   =0

   cod=conn_.Recv(1, )
   +=cod

   beforeTime = Time.now

after re-importing.

I'm pretty sure the stripping of all $words happens during export -- the php script that is produced on export is already missing $words.

I was hoping you might be able to easily spot the error in DeviceTemplate2php.php.  I'm not familiar with php or sql so I suspect it would be a bit of a learning curve for me to debug.

I've got improved Denon Receiver and Aquos TV templates I was hoping to share and backup with the help of this script.

Cheers,

Alex

posde

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2934
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #22 on: April 12, 2009, 01:14:11 pm »
Alex,

I will look into it. I have the logic correct, but I am too stupid to escape stuff correct.

Maybe I get things done in time for 0810 release.

alx9r

  • Guru
  • ****
  • Posts: 187
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #23 on: April 12, 2009, 06:26:45 pm »
I took a closer look at DeviceTemplate2php.php.  PHP evaluates variables ($words) and escape characters (i.e. \r \n) in strings automatically whenever it sees them in "double quotes".  In single quotes on the other hand, PHP does not evaluate them. 

How $words and /n, /r, etc are interpreted in nested mixed single and double quotes are interpreted by PHP is extremely hard to figure out.  I'm not even sure that interpretation of nested quotes in PHP is clearly defined.  In any case, when you have PHP code, sql statements, and ruby code all supposedly delimited by the same quotes that are included in the PHP code, sql statements, and ruby code it quickly turns into madness.

Maybe someone who is expert at PHP, sql, and ruby could unravel this script to make it work.  I think, however, the simplest solution is to rewrite the same script using a different language.  A language that has good sql support and string interpretation rules that lend themself to this sort of thing is key. 

I also think that if it is rewritten, the usage ought to be more like this:

To export:
Code: [Select]
ExportDeviceTemplate 1932

which would produce a file called "1932.dt".

To import:
Code: [Select]
ImportDeviceTemplate 1932.dt

Ideally the .dt files would be in a format that can be easily diffed.

If I can find the time I might undertake this myself.  I think it is important to be able to share device templates.  I think there might also be a role for import/export of device templates even when sqlCVS is working well -- device templates ought to be tested on a variety of installations before they are permanently committed to the code base. 

Regards,

Alex

merkur2k

  • Addicted
  • *
  • Posts: 513
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #24 on: May 19, 2009, 12:51:46 am »
I was asked to hack away at this script and this is what I came up with.
It now has a web user interface and prompts to save/load template files to the user's local drive. Encapsulation of the data is now done using php's serialize function which should prevent it from attempting to resolve any php tokens in the data.
I do not have a system to test out the import on so the best I have done for testing on that part is look over the generated sql queries. I would appreciate it if those with test systems could install it and test out a few different templates, particularly the ones giving problems above.
The file is in the trac ticket at http://svn.linuxmce.org/trac.cgi/ticket/208

posde

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2934
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #25 on: May 19, 2009, 09:39:08 am »
Thank you merkur2k for your work.

And yes, please, people!, test it!

If anyone has some exported templates, please feel free to filebin them someplace, and I shall try to import them in my test env.

alx9r

  • Guru
  • ****
  • Posts: 187
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #26 on: May 20, 2009, 01:34:53 am »
I was asked to hack away at this script and this is what I came up with.
It now has a web user interface and prompts to save/load template files to the user's local drive. Encapsulation of the data is now done using php's serialize function which should prevent it from attempting to resolve any php tokens in the data.
merkur2k,
That sounds great. 

Quote
I do not have a system to test out the import on so the best I have done for testing on that part is look over the generated sql queries. I would appreciate it if those with test systems could install it and test out a few different templates, particularly the ones giving problems above.
When I ran the output of the original script, it would generate a new copy (with the aforementioned problems of course) of the output device template.  The point is that you should be able to test the import by running the script on the same machine where the export took place -- it should generate an identical device template with a different device template id.

Regards,

Alex

merkur2k

  • Addicted
  • *
  • Posts: 513
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #27 on: May 20, 2009, 06:43:45 am »
I just used it to import some stuff into my new setup that I had before reinstalling the core and ran into some problems. Yeah the idea is to have it recreate the old device as a new one, but I see now that its going to need a bit more logic so that it knows to duplicate related data as well (if they havent changed then it doesnt export them, hence they dont get created in the import). Also screwed up the query generation, the field names shouldnt be quoted. Ill get an updated version out tomorrow probably.

ddamron

  • Alumni
  • wants to work for LinuxMCE
  • *
  • Posts: 962
    • View Profile
    • My LinuxMCE User Page
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #28 on: May 20, 2009, 08:31:28 am »
Oliver

just as I wrote to you: this is most of Dan's PLCBUS template. (I left some ruby code out but the big 373 routine is there)

by the way when I am trying to take existing one I am getting:

Code: [Select]
<?php
error_reporting(E_ALL);
$link mysql_connect("localhost","root");
mysql_select_db("pluto_main",$link);
$deviceTemplateID $newPK;
print "New DeviceTemplate: " $newPK;
?>


this is for template 1779

Eran.

What?!?  Is MY code causing Possy havoc?!?!? LOL
Sorry Possy :)

Glad to see someone is using that code... the framework is there for some really cool stuff...
and YES, it's a LOT of code.

That, along with the InsteonPLM code, are (as far as I know) the largest Ruby Templates in the system.

Only because I was trying to do way too many things :P

ahh well, it works, that's what counts :)

All the best,

Dan
The only intuitive interface is the nipple.  After that it's all learned.
My other computer is your windows box.
I'm out of my mind.  Back in 5 minutes.
Q:  What's Red and smells like blue paint?

A:  Red Paint.

phenigma

  • wants to work for LinuxMCE
  • **
  • Posts: 944
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #29 on: December 06, 2009, 11:13:37 pm »
I know this is digging up an old topic but I've been trying to use this feature to backup my TV and Receiver device templates in 0810b2 and I'm getting some errors and no apparent output file.

The output I'm getting is here: http://pastebin.com/m2039a033

I'm thinking of doing a fresh install and would love to backup these templates first.  Is this working for anyone else right now?

J.
« Last Edit: December 06, 2009, 11:28:22 pm by phenigma »