LinuxMCE Forums

General => Developers => Topic started by: posde on September 24, 2008, 01:21:52 pm

Title: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde on September 24, 2008, 01:21:52 pm
Hi,

usually, the course of action with LinuxMCE is, to utilize sqlCVS to commit a new device template for anyone to use it. Unfortunately, anonymous commits to sqlCVS have caused myself problems in the past. I had a need to export created device templates, to import those devices into a new LinuxMCE installation.

I created a small script called DeviceTemplate2php. This script can be called from a html page, and creates a new php file called device####.php, where #### is replaced with the original device template ID.

The small script is located at http://possy.de/DeviceTemplate2php.tar.gz (http://possy.de/DeviceTemplate2php.tar.gz) and should be stored on the LinuxMCE core in /var/www/ under the name DeviceTemplate2php.php. Now you can execute the file from your browser by using the url
http://dcerouter/DeviceTemplate2php.php?DeviceTemplateID=1933 (http://dcerouter/DeviceTemplate2php.php?DeviceTemplateID=1933)
in case you want to export your device template 1933.

Please try it out, and let me know any problems you might experience.

rgds
Oliver
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: Itsik on September 24, 2008, 06:53:17 pm
Thats great !  :)
I'll try it asap ...
One question, how do you import the template into another installation ?

thnx
Itsik
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde on September 24, 2008, 09:05:12 pm
Hello Itsik,

you execute the generated file on the command line. It is a PHP script that does the relevant SQL INSERT commands

rgds
Oliver
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: bulek on September 24, 2008, 10:47:42 pm
Hello Itsik,

you execute the generated file on the command line. It is a PHP script that does the relevant SQL INSERT commands

rgds
Oliver

Hi,

thanks for effort. It will be really useful... BTW, does this work also if you created new commands or other types of data along with new template that needs them ?

Thanks in advance,

Bulek.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde on September 24, 2008, 11:17:56 pm
Bulek,

try it out, I don't know, but the system tries its best to catch all related stuff (currently except the pnp shell script, as I don't know how to package it). It's a v0.01, so please be gentle, backup your data before, and just check it out.

rgds
Oliver
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: eran on September 28, 2008, 10:08:45 am
I have tried it:

and I got empty file and error:

Creating file /tmp/device1931dMMD0L

Notice: Undefined offset: 0 in /var/www/DeviceTemplate2php.php on line 128

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/DeviceTemplate2php.php on line 75

Notice: Undefined offset: 0 in /var/www/DeviceTemplate2php.php on line 128

Done creating file!

Now the file /tmp/device1931dMMD0L needs to be executed. Please do that on the command line using

php /tmp/device1931dMMD0L
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde on September 28, 2008, 12:02:36 pm
Eran,

thanks for testing.

I have tried it:
and I got empty file and error:
Creating file /tmp/device1931dMMD0L
Notice: Undefined offset: 0 in /var/www/DeviceTemplate2php.php on line 128
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/DeviceTemplate2php.php on line 75
Notice: Undefined offset: 0 in /var/www/DeviceTemplate2php.php on line 128
Done creating file!
Now the file /tmp/device1931dMMD0L needs to be executed. Please do that on the command line using
php /tmp/device1931dMMD0L

The file /tmp/device1931dMMD0L is empty? If yes, are you able to make a dump of your mysql database, and put it somewhere I can take a look at it?

rgds
Oliver
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: eran on September 28, 2008, 01:44:41 pm
Well chacked again - the file is not empty - I have to read it with root!

It looks like it has every thing inside
and if I try to execute it from command line (of course with root) - ./devi......

line 1: ?php: no such file or directory
line 2: syntax error near unexpected token 'E_ALL'
line 2: '      error_reporting('E_ALL');'

and no templete was add...
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde on October 01, 2008, 09:37:33 pm
eran,

you have to executed with the php interpreter, i.e.
Code: [Select]
php devic.....
rgds
Oliver
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: eran on October 06, 2008, 03:09:07 pm
well I think it is working but there are some error during the creation of the new template
fro example:
InfraredGroup: 5995
Notice: Undefined variable: line in /tmp/device1931olq20t on line 20

Notice: Undefined variable: index in /tmp/device1931olq20t on line 20

Notice: Undefined variable: waitTime in /tmp/device1931olq20t on line 20

Notice: Undefined variable: line in /tmp/device1931olq20t on line 20

Notice: Undefined variable: waitTime in /tmp/device1931olq20t on line 20

Notice: Undefined variable: line in /tmp/device1931olq20t on line 20

Notice: Undefined variable: line in /tmp/device1931olq20t on line 20

Notice: Undefined variable: line in /tmp/device1931olq20t on line 20

Notice: Undefined variable: line in /tmp/device1931olq20t on line 20

Notice: Undefined variable: line in /tmp/device1931olq20t on line 20
New DeviceTemplate: 1936

and checking template 1936 looks like a good template
I did not find where to cahnge the name of the device so I get two template for the same name...
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: eran on October 07, 2008, 12:09:45 pm
Hi again!
I am trying to build a back with the export procedure and for that I am trying to export more templates

now I tried to build the template to the PLC BUS export it - It look like everything there
and when trying to import it again i got:

root@dcerouter:~/Desktop# php device1938FV1q1t

Parse error: syntax error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/linuxmce/Desktop/device1938FV1q1t on line 15

and this is the file that was created: (device1938FV1q1t)
I tried to include  the code but I got "The message exceeds the maximum allowed length (20000 characters)."
so I cant add it here so if you need to see it tell me how to send you the file


I will try other different template and let you know about problems...

Tnx.
Eran.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde on October 09, 2008, 10:24:53 pm
Eran,

could you paste the problematic file to filebin.ca

thanks
rgds
Oliver
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: eran on October 10, 2008, 07:05:01 am
I could not work wiyh filebin.ca so I used other site:

http://www.uploadbigfiles.net/download.php?file=706device1938FV1q1t

Tnx.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde on October 10, 2008, 10:26:45 pm
Is that an existing template you are trying to Export, or did you create it new? It is definitly more complex than any of the ones I have played with. Is the device working correct?

A brief look just shows that it might be the length of the insert statement.

I will look into it. But please post any information you have for this as well.

Thanks

rgds
Oliver

Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: eran on October 11, 2008, 08:41:49 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.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde 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
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: eran 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...
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde 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
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: bulek 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.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: chriss 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
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: bulek 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
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: alx9r 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
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde 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.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: alx9r 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
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: merkur2k 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
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde 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.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: alx9r 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
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: merkur2k 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.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: ddamron 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
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: phenigma 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.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: alx9r on December 07, 2009, 02:25:18 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.
This may be an old thread, but I think it's still quite an important topic.  I think it's important to be able to import/export/share device templates without the permanence of sqlCVS.  To explain what I mean:

 - device template import/export would be for moving around experimental, untested, unproven, half-working, questionable quality device templates between installations
 - sqlCVS is for permanently storing and sharing well-tested, proven-working templates

Right now, I'm pretty sure this script is the closest thing to the former that exists.

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

I did get the script working for one of my many templates, however, it didn't work for most.  I can't remember if in the end it was failing out on execution, or if it was garbling the ruby code -- although I have seen it do both of those things.

This script is exactly the right idea, cheers to everyone who has got it this far.  It just needs to be progressed to the point where it works reliably.

Alex
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: phenigma on December 09, 2009, 08:49:15 pm
I did some playing and a little php/html learning and have altered the script to the point where it outputs a file I can save.  This part was pretty easy.  I don't know if the output is correct as I am not very familiar with the database.  I am unable to import the resulting file back into the database as I am getting sql errors on insert statements.  I am looking into this and will post any progress I make.

J.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: phenigma on March 04, 2010, 10:11:38 pm
I think this is an important abiltity to have and a presents a great learning opportunity to become more familiar with LinuxMCE, PHP, & MySQL.  Over the last couple days I've got the script more or less working to export and import basic user generated device templates.  I have tested this with a few IR A/V devices and I have also tried the PLCBUS template, programmed IR codes and ruby commands are exporting and importing .  The following is a list of some updates and issues:

Changes:
 * - fixed - quotes around field names are gone
 * - fixed - stores all rows from related tables rather than last row only
 * - fixed - updates DeviceTemplate FK's for new related table PK entries after inserts are done
 * - fixed - strings are escaped before inserting to db (ruby looks okay to me)
 * - added - preview insert/update statements before importing to DB
 * Known Issues:
 * - when previewing these are placeholder values PK_DeviceTemplate=-3, PK_InfraredGroup=-2
 * - does not set FK_Manufacturer, FK_DeviceCategory properly in related tables if new
 *   Manufacturer or DeviceCategory entries are inserted by the script
 * - does not export/import DHCPDevice PnpDetectionScript scripts - only DB entries
 * - does not import DTs marked 'old', use &forceExportType=new during export to be able to import
 * - no validation of data can create duplicate rows in tables when importing 'old' as 'new'
 * - I'm sure there's more...

Thanks posde and merkur2k I'm learning lots.  It has a ways to go to deal with all possibilities, and could be a little prettier, but it's in a state where it is worth doing some testing with.  I'd like to rename it at some point (posde?) as it no longer generates a PHP script.  DeviceTemplateRevolver (DTR) or DeviceTemplateXchanger (DTX)... or something.  I expect to tackle the issues mentioned above, feel free to add to the list if you find specific issues.  Backup your data before using.

Use:
 Exporting - the script will display the serialized data and ask you to confirm the export after which it will present the file download dialog.
 Importing - View or Import.  Default is View.  Choosing view will parse the selected file and display the generated insert/update statements without executing any of them.  Choosing Import will immediately execute the insert/update statements and display them at the same time.  Choose view the first time, verify the insert/update statements, hit the back button and choose Import to import the device.

Grab the updated script from: http://filebin.ca/mftsyp/DeviceTemplate2php.tar.gz

J.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde on March 05, 2010, 12:20:34 pm
phenigma,

could you attach the script to this thread, please.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: phenigma on March 06, 2010, 11:45:49 pm
Sure.  Here's a slightly updated version exporting and import viewing work well.  I need to scrub my virtual machine and test some more imports with the updates.  Simple IR based AV devices seem to work on native databases.

Changes:
 * 2010-03-06 - Changes by phenigma phenigma@hotmail.com
 * - fixed updates all entries' FK's for new PK entries after initial inserts
 * - fixed string escaping using mysql function (utf friendly?)
 * - fixed tables gets a unique fakeID when previewing rather than all related tables=-3
 * Known Issues:
 * - does not export/import any files/scripts - only DB entries
 * - does not import DTs marked 'old', use &forceExportType=new during export to test importing
 * - exports redundant data with &forceExportType=new
 * - may create duplicate rows when importing 'old' DTs exported with &forceExportType=new
 * - I'm sure there's lots more...
 
As I learn more about the database/sqlCVS and php/mysql I'm finding more to implement and better ways of doing things... 

J.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: phenigma on March 07, 2010, 12:26:59 am
It has occurred to me that when inserting devicetemplates into a new system that records should be linked on psc_id, where it exists, not by PK_ as the PK_ could be different where the psc_id should be identical across systems.  The script is still maintaining links by PK_ which could create problems where a DT depends on a table row added by an sqlCVS update.  I'll change this functionality to work on psc_id where it exists.

I'm only testing on 0810 but can I assume that psc_id's are not reused and a psc_id for a device under 0710 will still describe the same device in 0810?

J.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde on March 07, 2010, 07:51:15 am
The link between tables is ALWAYS by PK and FK.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: phenigma on March 07, 2010, 05:38:30 pm
Hi posde, yes I realize that, the link is always by PK and FK.  So let me explain what I mean.  The PK for a related table row (eg. Manufacturer) could be different on the system it's being imported to than it was on the exporting system because of sqlCVS updates.  To get around this the psc_id could be used to find the proper PK on the import machine (if it's different).

Example (Follow me here):
1.User1 installs a fresh 0810 system and creates a DeviceTemplate and then exports it and gives it to User2.  This device template refers to a manufacturer that was recently added to sqlCVS.

2.User2's system is older than User1's and User2 has created a new manufacturer before doing an sqlCVS update.  The sqlCVS update adds the manufacturer that User1's exported template is referring to.  Both users now have the same Manufacturer in their databases but with different PK's for that Manufacturer but the same psc_id.  This is how sqlCVS works isn't it?

3.Importing the DT into a new system by original PKs will link the imported Device to the incorrect Manufacturer on User2's system. 

The script will need to check the psc_id of the manufacturer and use it to select the the import machine's PK for that Manufacturer to properly link rows on the import machine... 

J.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: posde on March 08, 2010, 09:16:38 am
What needs to be remembered is: The device template exporter was never meant as a replacement for sqlCVS, but more of a last straw tool, when one has to re-install and hasn't had a chance to sqlCVS commit templates. I would not rely on the psc_id at all.

imho, the device template exporter should only be used locally, and not as a replacement for the central sqlCVS repo.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: phenigma on March 08, 2010, 04:28:16 pm
Gotcha. 

J.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: golgoj4 on October 10, 2010, 08:38:05 am
So whats the current disposition of this?
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: phenigma on October 10, 2010, 05:15:42 pm
I had done more work on it and had it working quite well and was moving my device templates around with ease from install to install.  Then I forgot to back it up one day and lost some of my recent work.  I'll have to dig it out again and see what state it's in.

J.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: golgoj4 on October 10, 2010, 08:50:18 pm
Sure.  Here's a slightly updated version exporting and import viewing work well.  I need to scrub my virtual machine and test some more imports with the updates.  Simple IR based AV devices seem to work on native databases.

Changes:
 * 2010-03-06 - Changes by phenigma phenigma@hotmail.com
 * - fixed updates all entries' FK's for new PK entries after initial inserts
 * - fixed string escaping using mysql function (utf friendly?)
 * - fixed tables gets a unique fakeID when previewing rather than all related tables=-3
 * Known Issues:
 * - does not export/import any files/scripts - only DB entries
 * - does not import DTs marked 'old', use &forceExportType=new during export to test importing
 * - exports redundant data with &forceExportType=new
 * - may create duplicate rows when importing 'old' DTs exported with &forceExportType=new
 * - I'm sure there's lots more...
 
As I learn more about the database/sqlCVS and php/mysql I'm finding more to implement and better ways of doing things... 

J.

Is this the most recent version?

Thanks to everyone who's worked on this btw, its a big deal when needing to recreate templates housewide.

-golgoj4
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: phenigma on October 10, 2010, 10:43:14 pm
That's likely the most recent I have.  I had done more work and fixed a few more things and cleaned up the code a bunch as I learned more but I havn't had a chance to see if I've got anything newer backed up anywhere.  I'll have to look.

The actual 'insert' code may be commented out in the posted version of the script to avoid accidentally screwing up a database, you may have to uncomment it at the end of the .php file to get it to actually insert records into your database.  When you are viewing the insert statements it will show negative numbers as place holders for new Primary Key IDs that will be created when the actual insert statements are run.

J.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: pw44 on October 10, 2010, 11:02:43 pm
I'm trying to export two templates i've created, but no luck.
The export shows errors and i cant find any file. http://www.pastebin.org/115322 shows it.
Question: how to export the templates and where are they stored, so i can backup them and submit to svn?
TIA
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: pw44 on October 12, 2010, 07:21:50 pm
Hia,
anyone knows how to export the templates and where they are stored after export?
I'm trying to use DeviceTemplate2php.php, but there are errors.
TIA,
Paulo
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: phenigma on October 12, 2010, 09:55:50 pm
I'm trying to export two templates i've created, but no luck.
The export shows errors and i cant find any file. http://www.pastebin.org/115322 shows it.
Question: how to export the templates and where are they stored, so i can backup them and submit to svn?
TIA


The script in the lmce distro does not function properly.  You may have better luck with one I posted earlier in this thread but I do not recall the state I left it in at this exact moment.  I will look at it again but don't have the time right this instant.

J.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: pw44 on October 12, 2010, 11:46:26 pm
Thx, J.
your version did the job. I will now submit both template to svn.
Kind regards,
Paulo
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: phenigma on October 17, 2010, 08:28:40 am
Paulo,

I'm glad it was successful for you!  My intent was to enhance the ability for testing device templates from install to install without having yet submitted them to sqlcvs.  I'd love to know what the devices were that you exported and what your experiences were using the script, it's not the easiest to use. 

Did you have any problems?
Did you have to alter anything in the script?
Were the devices IR or GSD? or neither?
Did all the IR/GSD code transfer properly? 

I hope to clean it up a bunch and create a better interface some day.  I had used the script as an exercise to learn a some php and sql so my additions to the original code were not the prettiest in implementation.  I learned a whole lot about the pluto_main database structure in relation to device templates.  Somewhere I have additions that add the ability to backup shell scripts (setup & pnp detect scripts, etc.) associated with the device template, and all child entries, and code that does device template association by psc_id in-case someone updates their sqlcvs after backing up but before restoring (I experienced a problem with this once and wanted to account for it).  I don't remember how much of that is in the one I posted.  At some point I'll look at what's here and the changes I'd made since then and merge them.

Again, glad it worked for you!  Tell me how it went!

J.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: pw44 on October 17, 2010, 10:12:18 pm
Hi J.,
yes, the devices templates were exported, manufacturer pointed as: "FK_Manufacturer";s:4:"1057", model indicated correctly: "Description";s:14:"SoundBridge IR".
I submitted both templates and am waiting for an answer if they were accepted or not.
Let's wait to see how it goes....
Thx again.
Paulo

P.S. It would be nice to be able to set the effect (and if effect is to be used) for the given source, like files defined as movies, selecting DTS, files defined as audio and jazz, selecting Jazz Club, audio and rock, selecting Rock Concert, TV selecting Theater..
Most of the middle to to range audio/video receivers and amplifiers has multiple effect modes.
I could not find how to set it, so i do it with the amp remote.. selecting the effect mode.
Title: Re: Exporting Device Templates - ignoring sqlCVS for the moment
Post by: phenigma on October 22, 2010, 10:51:16 pm
Hi J.,
yes, the devices templates were exported, manufacturer pointed as: "FK_Manufacturer";s:4:"1057", model indicated correctly: "Description";s:14:"SoundBridge IR".
I submitted both templates and am waiting for an answer if they were accepted or not.
Let's wait to see how it goes....

Your templates will not be accepted if they are submitted in this format.  This was a mechanism that was attempted when sqlCVS was less reliable and for people testing devicetemplates across installs before submitting them properly.  If you want your templates accepted into LMCE then you will have to submit them using sqlCVS, I think the wiki has a howto you can follow.

Thx again.
Paulo

P.S. It would be nice to be able to set the effect (and if effect is to be used) for the given source, like files defined as movies, selecting DTS, files defined as audio and jazz, selecting Jazz Club, audio and rock, selecting Rock Concert, TV selecting Theater..
Most of the middle to to range audio/video receivers and amplifiers has multiple effect modes.
I could not find how to set it, so i do it with the amp remote.. selecting the effect mode.

Search around, there are a few threads that discuss this topic and I know the IR codes are accounted and I think the fields are provided and available in the database but I don't think the relevant code has not been created to enable these settings to apply automatically during use.

J.