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

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Exporting Device Templates - ignoring sqlCVS for the moment
« 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 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
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

Itsik

  • Guru
  • ****
  • Posts: 190
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #1 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

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #2 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

bulek

  • Administrator
  • wants to work for LinuxMCE
  • *****
  • Posts: 909
  • Living with LMCE
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #3 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.
Thanks in advance,

regards,

Bulek.

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #4 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

eran

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #5 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

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #6 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

eran

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #7 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...

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #8 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

eran

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #9 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...

eran

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #10 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.

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #11 on: October 09, 2008, 10:24:53 pm »
Eran,

could you paste the problematic file to filebin.ca

thanks
rgds
Oliver

eran

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #12 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.

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #13 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


eran

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Exporting Device Templates - ignoring sqlCVS for the moment
« Reply #14 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.