Unable to import directory tree from command line

nivla

Joined: 2005-03-25
Posts: 5
Posted: Fri, 2005-03-25 16:29

I've installed gallery-2.0-beta-1 onto my gentoo system with mysql 4.0.24 and perl v5.8.5.
I'm trying very hard to import my huge directory tree of pictures (about 10K) into gallery while maintaining the directory structure.

Unsuccessfully, I have tried the g2add.pl and galleryadd.pl scripts as well as that within the galleryadd.tar.gz archive downloaded from http://galleryupdates.jpmullan.com/.

The first problem seems to be that it can not find the name of the specified album. A little debugging within the g2add.pl script reveals that this is because it is not searching for the album name but instead some number which represents the album. Once that number is substituted, I get the following error:

Could not create album 'blah blah blah' : Unknown error 200
<b>Fatal error</b>: Call to a member function on a non-object in <b>/blah/gallery2/modules/remote/GalleryRemote.inc</b> on line <b>81</b><br />

The ability to perform this import is essential for my use of gallery as it would be impossible for me to do so outside of gallery.

Lastly, I would really, really love a command-line tool or api which would allow me to import the pictures directly without having to tax my already taxed web-server.

Thanks in advance for your time, help, and expediance.

 
jmullan
jmullan's picture

Joined: 2002-07-28
Posts: 974
Posted: Sat, 2005-03-26 00:03

You didn't supply most of the information from the support template:
Please do, and we'll do our best to help you.

<TYPE YOUR MESSAGE HERE, ENTER SYSTEM DETAILS BELOW>
<Please check the G2 FAQ (sticky topic in this forum) before posting!>
----

Gallery URL (optional):
Gallery version:
Webserver (with version):
Datatabase (with version):
PHP version (eg 4.2.1):
phpinfo URL (optional):
Graphics Toolkit(s):
Operating system:
Web browser/version:
G1 version (for migration bugs):

 
jmullan
jmullan's picture

Joined: 2002-07-28
Posts: 974
Posted: Sat, 2005-03-26 00:07

It's not debugging if it was caused by user error. You entered the wrong arguments for g2add.pl. ;)

galleryadd.pl won't work with g2 at all.

Did you try the "add from local server" option in g2 itself? It should be able to import recursively.

 
nivla

Joined: 2005-03-25
Posts: 5
Posted: Sat, 2005-03-26 06:19

Sorry....I've included the system info at the end of the message

The arguments listed for the g2add.pl script were the following.
g2add.pl -l url -a album -u username -p password filenames [-c] [-q] files dirs

I initially entered the following:
./g2add.pl -a 'album name' -l http://localurl -u name -p pass /localdir

After receiving, album not found error, I added several print statements to the script, saw "album.name.1=6", and assumed that my album name was, in fact, 6.

After entering the following, I got further and received the could not create error.
./g2add.pl -a 6 -l http://localurl -u name -p pass /localdir

I also just realized that the version of the g2add.pl is Version: .08G2alpha. This was true of the all of the ones that I could find at the website. Could it be that I have the wrong version?

Lastly, I'm unable to use the "add from local server" option in g2 because it does not maintain the directory structure, by adding sub-albums. Is it possible that this option could be added in the future?

gallery-2.0-beta-1
gentoo kernel 2.6.11
mysql 4.0.24
perl v5.8.5.
apache 2.0.52
php 4.3.10
ffmpeg 0.4.7
netpbm 10.20
jhead 2.0

 
jmullan
jmullan's picture

Joined: 2002-07-28
Posts: 974
Posted: Sat, 2005-03-26 07:31

Hmm. I could have sworn that I had updated the usage. Oh well, it's updated now.

It might help to set
my $gallery_log = 1;
and set
my $gallery_log_filename = '~/g2add.log';
to someplace useful

or, try just setting
my $gallery_log_open = 1;

I think that will direct the detailed output to standard out.

Please paste your full log here or email it to me at

Thanks!

 
nivla

Joined: 2005-03-25
Posts: 5
Posted: Sat, 2005-03-26 22:23

I downloaded the new g2add.pl script from http://galleryupdates.jpmullan.com/other/g2add.pl that was dated 03-26-2005 01:28:26 AM. I tried using the command unsuccessfully both ways: specifying the album name and "album id." I have included the output from both commands below.

I'm currently using gallery version: 2.0-beta-1. Do I need to use a later version for this to work?

Here's the output when specifying the album name

command:
./g2add.pl -a 'Members' -l http://url -u user -p password /picture-path

output:
Logging In
writing to log file
Logged In successfully
Fetching list of albums (may be slow)
Fetched list of albums.
#__GR2PROTO__
album.name.1=6
album.name.2=10
album.name.3=11
album.name.4=38
album.parent.1=0
album.parent.2=6
album.parent.3=6
album.parent.4=6
album.perms.add.1=false
album.perms.add.2=false
album.perms.add.3=false
album.perms.add.4=false
album.perms.create_sub.1=false
album.perms.create_sub.2=false
album.perms.create_sub.3=false
album.perms.create_sub.4=false
album.perms.del_alb.1=false
album.perms.del_alb.2=false
album.perms.del_alb.3=false
album.perms.del_alb.4=false
album.perms.write.1=false
album.perms.write.2=false
album.perms.write.3=false
album.perms.write.4=false
album.summary.1=
album.summary.2=
album.summary.3=
album.summary.4=
album.title.1=Gallery
album.title.2=Members
album.title.3=Curtis Johnson
album.title.4=Curtis Johnson
album_count=4
can_create_root=true
status=0
Album does not exist: Members

Here's the output when specifying the album id

command:
./g2add.pl -a 6 -l http://url -u user -p password /picture-path

output:
Logging In
writing to log file
Logged In successfully
Fetching list of albums (may be slow)
Fetched list of albums.
#__GR2PROTO__
album.name.1=6
Found album '6'
album.name.2=10
album.name.3=11
album.name.4=38
album.parent.1=0
album.parent.2=6
album.parent.3=6
album.parent.4=6
album.perms.add.1=false
album.perms.add.2=false
album.perms.add.3=false
album.perms.add.4=false
album.perms.create_sub.1=false
album.perms.create_sub.2=false
album.perms.create_sub.3=false
album.perms.create_sub.4=false
album.perms.del_alb.1=false
album.perms.del_alb.2=false
album.perms.del_alb.3=false
album.perms.del_alb.4=false
album.perms.write.1=false
album.perms.write.2=false
album.perms.write.3=false
album.perms.write.4=false
album.summary.1=
album.summary.2=
album.summary.3=
album.summary.4=
album.title.1=Gallery
album.title.2=Members
album.title.3=Curtis Johnson
album.title.4=Curtis Johnson
album_count=4
can_create_root=true
status=0
Ignoring /picture-path

 
nivla

Joined: 2005-03-25
Posts: 5
Posted: Thu, 2005-03-31 19:28

If needed, I can update the script so that it will recursively add the pictures while maintaining the directory tree. Where could I go to find the latest version of these scripts and the current design documents outlining the (php) class and (mysql) database structure? Additionally, how could I become/apply to become a developer for this project?

Thanks for your help.

 
jmullan
jmullan's picture

Joined: 2002-07-28
Posts: 974
Posted: Thu, 2005-03-31 20:13

What user are you trying to log in as? Does that user have permission to add to the root album?

 
nivla

Joined: 2005-03-25
Posts: 5
Posted: Thu, 2005-03-31 21:52

I am using an administrative user who I believe has sufficient permissions as it (the user) can create a sub-album from within the web pages.

 
PabloHoffman

Joined: 2005-10-04
Posts: 1
Posted: Tue, 2005-10-04 13:48

Same thing happened to me. Here is a small patch to fix the "Album not found" problem for g2add.pl version .091G2alpha (the one available on jpmullan.com right now)

Regards,
Pablo Hoffman

--- g2add.pl.orig	2005-05-28 02:45:05.000000000 -0300
+++ g2add.pl	2005-10-04 09:18:28.259670528 -0300
@@ -114,6 +114,7 @@
 #  derived from arguments
 my $gallery_location;
 my $gallery_albumid;
+my $this_albumid;
 my $gallery_username;
 my $gallery_password;
 my $gallery_setcaption;
@@ -393,16 +394,18 @@
 	my $number = shift(@foo);
 	if ($fieldname eq 'name') {
 	    $albums[$number]['name'] = join('=',@value);
+           $this_albumid = $albums[$number]['name'];
 	    push (@albumnames,join('=',@value));
-	    if ($gallery_albumid eq $albums[$number]['name']) {
-		$gallery_album_exists = 1;
-		if (!$gallery_runquiet) {
-		    print "Found album '$gallery_albumid'\n";
-		}
-	    }
 	}
 	if ($fieldname eq 'title') {
 	    $albums[$number]['title'] = join('=',@value);
+	    if ($gallery_albumid eq $albums[$number]['title']) {
+            if (!$gallery_runquiet) {
+                print "Found album '$gallery_albumid'\n";
+            }
+            $gallery_album_exists = 1;
+            $gallery_albumid = $this_albumid;
+	    }
 	}
 	if ($fieldname eq 'perms.add') {
 	    $albums[$number]['add'] = join('=',@value);

 
REDONDOS

Joined: 2004-02-21
Posts: 4
Posted: Sun, 2006-06-18 19:56

Hello. I'm having a hard time uploading images to my gallery using g2add.pl. Without PabloHoffman's patch, the script complains about the albums not being there. With it, it supposedly succeeds, but after waiting a while for the upload to finish, the images aren't in there at all.

Here's a session log:

redondos@refinery:~/pictures/2006-03-11 - Vecino Gonzalo/temp$ g2add.pl  -l http://gallery.redondos.biz -u redondos -p <password> -a "2006-03-11-VecinoGonzalo" DSC03879.JPG -c
Logging In
Logged In successfully
Fetching list of albums (may be slow)
Fetched list of albums.
Found album '2006-03-11-VecinoGonzalo'
Uploading image 'DSC03879.JPG'
setcaption active
POST http://gallery.redondos.biz/main.php
Content_Type => 'form-data'
Content      => 
	g2_controller => remote:GalleryRemote
	protocol_version => 2.5
	cmd => 'add-item'
	set_albumName => 3755
	caption => DSC03879
	g2_userfile => "DSC03879.JPG"

#__GR2PROTO__
status=0
status_text=Add photo successful.
item_name=11866
debug_user=redondos
debug_time=0.307s
Image 'DSC03879.JPG' uploaded successfully

Thanks in advance.