smugmug command line tool in python

13

Comments

  • heinz eheinz e Registered Users Posts: 5 Beginner grinner
    edited August 8, 2006
    Anything newer than 1.10
    Download sm_tool.py

    I use ver 1.10 as above. I have modified it slightly to
    get it to work. (Swedish national characters in directory
    names will not work.)

    Is the script maintained by anyone?
    Are there newer versions than 1.10 available.
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited August 8, 2006
    I wrote it and use it all the time. I'll look at bugs. There are a few other people around who also use it. If you have some fixes, post a new version or a patch here and Michael who hosts it will probably pick it up.
    If not now, when?
  • tdhock@ocf.berkeley.edutdhock@ocf.berkeley.edu Registered Users Posts: 1 Beginner grinner
    edited August 20, 2006
    comment on strings in source code
    rutt wrote:
    I wrote it and use it all the time. I'll look at bugs. There are a few other people around who also use it. If you have some fixes, post a new version or a patch here and Michael who hosts it will probably pick it up.
    This isn't a bug --- just a comment. I'm a python programmer as well and I noticed that your long help message is encoded in your source by repeatedly using string concatenation over multiple lines. An easier way to do this in python is by using triple quotes, i.e.

    self.parser = OptionParser(
    self.short_usage + """
    Create smugmug galleries and upload to them. Mirror directory trees
    on smugmug and keep up to date.
    ...
    """

    The tool seems to work nicely so far. Great work!
  • jmrodrijmrodri Registered Users Posts: 19 Big grins
    edited October 5, 2006
    Packaged for Fedora Core
    I love sm_tool.py. I've packaged it up in an RPM for use with Fedora Core. I use it daily. Is the code hosted anywhere? i.e. sourceforge, etc.?

    jesus rodriguez
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited October 5, 2006
    jmrodri wrote:
    I love sm_tool.py. I've packaged it up in an RPM for use with Fedora Core. I use it daily. Is the code hosted anywhere? i.e. sourceforge, etc.?

    jesus rodriguez

    I appreciate that. I wrote this thing as personal software to solve a problem of my own. I've never gotten a good sense of how many people actually use this (though I think the SM people might be able to answer this.)

    Anyway, it's never really grown out of a very informal sort of sharing. I'd be happy if someone picked it up and helped it grow up and move away from its parent's home.
    If not now, when?
  • jmrodrijmrodri Registered Users Posts: 19 Big grins
    edited October 7, 2006
    rutt wrote:
    I appreciate that. I wrote this thing as personal software to solve a problem of my own. I've never gotten a good sense of how many people actually use this (though I think the SM people might be able to answer this.)

    Anyway, it's never really grown out of a very informal sort of sharing. I'd be happy if someone picked it up and helped it grow up and move away from its parent's home.

    If you don't mind, I would be happy to create a sourceforge type project for
    it. And be the Fedora Core package maintainer for it. I will post here with
    the project site once it's ready.

    sincerely,
    jesus rodriguez
  • jmrodrijmrodri Registered Users Posts: 19 Big grins
    edited October 7, 2006
    jmrodri wrote:
    If you don't mind, I would be happy to create a sourceforge type project for
    it. And be the Fedora Core package maintainer for it. I will post here with
    the project site once it's ready.

    sincerely,
    jesus rodriguez

    sm_tool is not a valid project name, smtool conflicts with an existing
    sourceforge project. If you don't mind I'd like to name it
    sm-photo-tool. Let me know if that's ok. If you don't care, let me know
    as well :)
  • jmrodrijmrodri Registered Users Posts: 19 Big grins
    edited October 7, 2006
    Here is the home of sm_tool.py. As I said earilier, sm_tool was
    an invalid project name. So I used sm-photo-tool.
    http://code.google.com/p/sm-photo-tool/

    I will be checking in the Fedora Core packaging later this week.
  • bluemeaniebluemeanie Registered Users Posts: 3 Beginner grinner
    edited November 13, 2006
    Smuggle
    Hi,

    Nice tool. I actually took part of the scipt, enhanced and modified it to make it easy to mirror galleries between multiple accounts. If your a programmer and need an interface to work with smugmug galleries you may find it useful. Thanks!

    http://www.realityforge.org/articles/2006/11/14/smuggle
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited October 17, 2007
    My version of this script stopped working for me on Sunday (after chugging along unchanged for years.) The power of open-source payed off and before I even got around to trying to debug it, the sm_tool.py user community found and submitted a bug fix. Basiccally, use a different URL for initializing the connection, and pass the API key.

    Here is a diff:
    --- sm_tool.py.~6~      2006-09-17 10:49:45.000000000 -0400
    +++ sm_tool.py  2007-10-16 19:52:24.000000000 -0400
    @@ -162,10 +162,11 @@
       def __init__(self,account,passwd):
         self.account = account
         self.password = passwd
    -    self.sp = ServerProxy("https://upload.smugmug.com/xmlrpc/")
    -#    self.sp = ServerProxy("https://api.smugmug.com/hack/xmlrpc/beta.mg",
    -#                          transport=CURLTransport())
    +#    self.sp = ServerProxy("https://upload.smugmug.com/xmlrpc/")
    +    self.sp = ServerProxy("https://api.smugmug.com/hack/xmlrpc/1.1.1/",
    +                          transport=CURLTransport())
         self.api_version = "1.0"
    +    self.api_key = "COZkd1MBtHQtgs0zf2OQ4KTaiIk3ehVs"
         self.categories = None
         self.subcategories = None
         self.login()
    @@ -174,7 +175,9 @@
         self.logout()
    
       def login(self):
    -    rep = self.sp.loginWithPassword(self.account,self.password,self.api_version)
    +    rep = self.sp.loginWithPassword(self.account,self.password,
    +                                    self.api_version,
    +                                    self.api_key)
         self.session = rep['SessionID']
    
       def logout(self):
    
    If not now, when?
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited October 17, 2007
    rutt,

    you may want to replace the version of the script linked in the original post.

    thumb.gif

    David
    David Parry
    SmugMug API Developer
    My Photos
  • jmrodrijmrodri Registered Users Posts: 19 Big grins
    edited October 17, 2007
    rutt wrote:
    I'm sorry, I've had sort of an IT infrastructure meltdown and I no longer have a great way to provide access to script, at least until September. I've sent mdm a copy of the most recent version of the script. Great if he hosts it.

    I put the script under subversion:
    http://sm-photo-tool.sourceforge.net/

    Download the release here:
    http://sourceforge.net/projects/sm-photo-tool
  • gymshotsgymshots Registered Users Posts: 20 Big grins
    edited October 18, 2007
    Help with sm_-tool.py
    Hi Rutt...

    I use your tool often (thanks!) and noticed it is broken, too. I tried to make your changes - but when I try to login, I get the following errors below.

    (mind you I wrote an extension to your tool that I have been using for over a year, unchanged. It allows me to plug in the photograph ID from the URL and look up the name of my photograph in the command line.)

    $ sm_tool.py getFileInfo 193759560
    Traceback (most recent call last):
    File "/usr/bin/sm_tool.py", line 744, in ?
    main()
    File "/usr/bin/sm_tool.py", line 735, in main
    getInfo(argv[2],Options(argv[3:]))
    File "/usr/bin/sm_tool.py", line 672, in getInfo
    smugmug = Smugmug(opts.login,opts.password)
    File "/usr/bin/sm_tool.py", line 186, in __init__
    transport=CURLTransport())
    NameError: global name 'CURLTransport' is not defined

    here is the fragment of script changes:

    class Smugmug:
    def __init__(self,account,passwd):
    from sys import stderr
    # probably don't need to hard code this after all - FIXXME
    self.account = account
    self.password = password
    self.sp = ServerProxy("https://api.smugmug.com/hack/xmlrpc/1.1.1/",
    transport=CURLTransport())
    self.api_version = "1.0"
    self.api_key = "COZkd1MBtHQtgs0zf2OQ4KTaiIk3ehVs"
    self.categories = None
    self.subcategories = None
    self.login()
    self.logout()

    def login(self):
    rep = self.sp.loginWithPassword(self.account,self.password,
    self.api_version,
    self.api_key)
    self.session = rep

    def logout(self):
    self.sp.logout(self.session)


    any ideas?

    thanks for the help and the script!!
    Susan Jones
  • gymshotsgymshots Registered Users Posts: 20 Big grins
    edited October 18, 2007
    how to unpack?
    jmrodri wrote:
    I put the script under subversion:
    http://sm-photo-tool.sourceforge.net/

    Download the release here:
    http://sourceforge.net/projects/sm-photo-tool

    I went to source forge and downloaded the latest versions, but I don't know what to do with the .rpm and .tar files?

    thanks
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited October 19, 2007
    Oops, you need to have a bunch of curl stuff installed for that curlTransport parameter to work. Just omit it and you will be fine, if a little slower.
    gymshots wrote:
    Hi Rutt...

    I use your tool often (thanks!) and noticed it is broken, too. I tried to make your changes - but when I try to login, I get the following errors below.

    (mind you I wrote an extension to your tool that I have been using for over a year, unchanged. It allows me to plug in the photograph ID from the URL and look up the name of my photograph in the command line.)

    $ sm_tool.py getFileInfo 193759560
    Traceback (most recent call last):
    File "/usr/bin/sm_tool.py", line 744, in ?
    main()
    File "/usr/bin/sm_tool.py", line 735, in main
    getInfo(argv[2],Options(argv[3:]))
    File "/usr/bin/sm_tool.py", line 672, in getInfo
    smugmug = Smugmug(opts.login,opts.password)
    File "/usr/bin/sm_tool.py", line 186, in __init__
    transport=CURLTransport())
    NameError: global name 'CURLTransport' is not defined

    here is the fragment of script changes:

    class Smugmug:
    def __init__(self,account,passwd):
    from sys import stderr
    # probably don't need to hard code this after all - FIXXME
    self.account = account
    self.password = password
    self.sp = ServerProxy("https://api.smugmug.com/hack/xmlrpc/1.1.1/",
    transport=CURLTransport())
    self.api_version = "1.0"
    self.api_key = "COZkd1MBtHQtgs0zf2OQ4KTaiIk3ehVs"
    self.categories = None
    self.subcategories = None
    self.login()
    self.logout()

    def login(self):
    rep = self.sp.loginWithPassword(self.account,self.password,
    self.api_version,
    self.api_key)
    self.session = rep

    def logout(self):
    self.sp.logout(self.session)


    any ideas?

    thanks for the help and the script!!
    Susan Jones
    If not now, when?
  • gymshotsgymshots Registered Users Posts: 20 Big grins
    edited October 19, 2007
    that worked - but ... encountering error with my extension to sm_tool
    Thanks, that at least got me logged in. But now I am getting an error in the extension I wrote. I wondered if I could ask for your help a little further....I'm not a strong python programmer....I'll show you the error I am getting and the function I wrote to take the image ID and return the file name....maybe you have an idea....It must be because of the recent changes to the API...

    getFileInfo is supposed to take the Image ID and return the file name and album name to the screen.

    getInfoFiles works on a file that lists a batch of URLs from smugmug and returns a file with a .out extension where it has decoded the URL into its actual file name and gallery name.

    here's the error (to be followed by the script)

    $ sm_tool.py getFileInfo 193759560
    Traceback (most recent call last):
    File "/usr/bin/sm_tool.py", line 745, in ?
    main()
    File "/usr/bin/sm_tool.py", line 736, in main
    getInfo(argv[2],Options(argv[3:]))
    File "/usr/bin/sm_tool.py", line 674, in getInfo
    smugmug.getInfo_file(image_id,opts,rest)
    File "/usr/bin/sm_tool.py", line 358, in getInfo_file
    fileInfo = self.sp.getImageInfo(self.session, int(imageId))
    File "/usr/lib/python2.4/xmlrpclib.py", line 1096, in __call__
    return self.__send(self.__name, args)
    File "/usr/lib/python2.4/xmlrpclib.py", line 1383, in __request
    verbose=self.__verbose
    File "/usr/lib/python2.4/xmlrpclib.py", line 1147, in request
    return self._parse_response(h.getfile(), sock)
    File "/usr/lib/python2.4/xmlrpclib.py", line 1286, in _parse_response
    return u.close()
    File "/usr/lib/python2.4/xmlrpclib.py", line 744, in close
    raise Fault(**self._stack[0])
    xmlrpclib.Fault: <Fault 4: 'invalid user (missing/incorrect album password)'>



    and here is the implementation of getFileInfo


    I modified main() to accept two new commands

    elif argv[1] == '--help':
    Options(argv[1:])
    elif argv[1] == 'getFileInfo':
    if len(argv) < 2:
    Options([]).help()
    getInfo(argv[2],Options(argv[3:]))
    elif argv[1] == 'getInfoFiles':
    if len(argv) < 2:
    Options([]).help()
    getInfoFiles(argv[2],Options(argv[3:]))
    else:
    Options([]).help()


    and here are the two new methods

    def getInfo(image_id,options):
    opts = options.options
    rest = options.args
    smugmug = Smugmug(opts.login,opts.password)
    smugmug.getInfo_file(image_id,opts,rest)

    def getInfoFiles(imageListFilename,options):
    opts = options.options
    rest = options.args
    smugmug = Smugmug(opts.login,opts.password)
    smugmug.getInfo_files(imageListFilename,opts,rest)


    and here are the methods called from the smugmug instance

    def getInfo_file(self,imageId,opts,rest):
    fileInfo = []
    fileInfo = self.sp.getImageInfo(self.session, int(imageId))
    message(opts,"\n filename is %s\n" % (
    fileInfo["FileName"]))
    albumInfo = []
    albumInfo = self.sp.getAlbumInfo(self.session, fileInfo["AlbumID"])
    message(opts,"\n albumTitle is %s\n" % (
    albumInfo["Title"]))

    def getInfo_files(self,imageFile,opts,rest):
    if not path.isfile(imageFile):
    raise "ImageFile %s is not a file" % (imageFile)

    outputFileName = imageFile + '.out'
    fileHandle = open ( outputFileName, 'wa' )
    f = file(imageFile,"rU")
    try:
    option = None
    for lwithnl in f:
    l = lwithnl[:-1]
    imageIndex = string.rfind(l,"#")
    if imageIndex == -1:
    imageIndex = string.rfind(l,"/")
    if imageIndex != -1:
    imageIdIndex = imageIndex+1
    imageIdString = (l[imageIdIndex:])
    fileInfo = []
    fileInfo = self.sp.getImageInfo(self.session, int(imageIdString))
    message(opts,"Image: %s Filename is %s\n" % (
    imageIdString, fileInfo["FileName"]))
    albumInfo = []
    albumInfo = self.sp.getAlbumInfo(self.session, fileInfo["AlbumID"])
    fileHandle.write("%s!%s\n" % (
    albumInfo["Title"],
    fileInfo["FileName"]))
    finally:
    fileHandle.close()
    f.close()



    any help you have to offer is greatly appreciated! I use these all the time for my business....

    thanks!
    Susan

    rutt wrote:
    Oops, you need to have a bunch of curl stuff installed for that curlTransport parameter to work. Just omit it and you will be fine, if a little slower.
  • wmburkewmburke Registered Users Posts: 5 Beginner grinner
    edited February 10, 2008
    Problems uploading
    Hello all,

    I uploaded several directory trees containing a large number of pictures over the weekend, only to find that on SmugMug only galleries were created, but no images populate them. I have no errors from sm-photo-tool to figure out what's going on. Please help.

    I'm running Ubuntu Linux 7.10 with Python 2.5.

    Last Friday, I implemented the fix referred to by rutt above to my version 1.10 of the script, including removal of the CurlTransport portion of the fixes - everything seemed to work great and I watched by computer chug away all weekend uploading the files.

    I had successfully used the script to upload previously - back in September.

    If there's any other info I need to provide, I'll be happy to do so.

    Thanks,
    Wayne
  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited February 10, 2008
    wmburke wrote:
    Hello all,

    I uploaded several directory trees containing a large number of pictures over the weekend, only to find that on SmugMug only galleries were created, but no images populate them. I have no errors from sm-photo-tool to figure out what's going on. Please help.

    I'm running Ubuntu Linux 7.10 with Python 2.5.

    Last Friday, I implemented the fix referred to by rutt above to my version 1.10 of the script, including removal of the CurlTransport portion of the fixes - everything seemed to work great and I watched by computer chug away all weekend uploading the files.

    I had successfully used the script to upload previously - back in September.

    If there's any other info I need to provide, I'll be happy to do so.

    Thanks,
    Wayne

    G'day Wayne,

    It might be related to the new security measures we implemented, can you please email me your latest script to have a look at ? send it to david at smugmug

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • wmburkewmburke Registered Users Posts: 5 Beginner grinner
    edited February 15, 2008
    Many thanks to Dave Parry for his quick and easy help on solving my issue. He sent me a new copy of the script and all works fine now.

    The script that I was using I downloaded from sm-photo-tool.sourceforge.net, and am not sure what the difference is between the two.

    Either way, thanks to all for a great tool,

    Wayne
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited February 28, 2008
    wmburke wrote:
    Many thanks to Dave Parry for his quick and easy help on solving my issue. He sent me a new copy of the script and all works fine now.

    The script that I was using I downloaded from sm-photo-tool.sourceforge.net, and am not sure what the difference is between the two.

    Either way, thanks to all for a great tool,

    Wayne

    Hey, can you guys send a dif or something so I don't have to reinvent it? Thanks.
    If not now, when?
  • jmrodrijmrodri Registered Users Posts: 19 Big grins
    edited April 14, 2008
    gymshots wrote:
    I went to source forge and downloaded the latest versions, but I don't know what to do with the .rpm and .tar files?

    thanks

    The version in sourceforge was my attempt at putting sm-photo-tool into a source control system to track the changes. I asked rutt if I could do this some time ago.

    .rpm and .tar files are for Linux (or Unix variants). If you need it for windows I'm sure I can make sure I generate a zip file for you on sourceforge.

    Also, I'm trying to scour this forum for patches that I can import into the sourceforge project.
  • spencer Lambertspencer Lambert Registered Users Posts: 3 Beginner grinner
    edited April 16, 2008
    wmburke wrote:
    Many thanks to Dave Parry for his quick and easy help on solving my issue. He sent me a new copy of the script and all works fine now.

    The script that I was using I downloaded from sm-photo-tool.sourceforge.net, and am not sure what the difference is between the two.

    Either way, thanks to all for a great tool,

    Wayne

    I'm also having this same issue. I tried the latest version from sourceforge.net. I even tried the version in the head of the repository - (version 1.13). Can you send me over the file that is working for you?
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited April 17, 2008
    Hmm. The version I use (which works thanks to David) is very different from the version in sourceforge. My version is available here. I hope some ambitious soul will merge the best from both versions.
    If not now, when?
  • spencer Lambertspencer Lambert Registered Users Posts: 3 Beginner grinner
    edited April 19, 2008
    rutt wrote:
    Hmm. The version I use (which works thanks to David) is very different from the version in sourceforge. My version is available here. I hope some ambitious soul will merge the best from both versions.

    I get this when I follow your link....

    Not Found

    The requested URL /sm-app.tar.gz was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited April 20, 2008
    Link fixed now: here
    If not now, when?
  • jmrodrijmrodri Registered Users Posts: 19 Big grins
    edited April 23, 2008
    rutt wrote:
    Hmm. The version I use (which works thanks to David) is very different from the version in sourceforge. My version is available here. I hope some ambitious soul will merge the best from both versions.

    I will be happy to merge the two. I've been maintaining it in sourceforge.
  • jmrodrijmrodri Registered Users Posts: 19 Big grins
    edited April 23, 2008
    Speaking of the sourceforge version, I have released version 1.13 tonight.
    Download it here:
    http://sourceforge.net/project/showfiles.php?group_id=179298

  • jmrodrijmrodri Registered Users Posts: 19 Big grins
    edited April 23, 2008
    sm-photo-tool bugs
    If you have problems with the sm-photo-tool in sourceforge, please file a bug here:
    http://sourceforge.net/tracker/?group_id=179298&atid=888591
  • spencer Lambertspencer Lambert Registered Users Posts: 3 Beginner grinner
    edited April 27, 2008
    rutt wrote:
    Link fixed now: here

    FYI, this version/file did not fix the issue for me. I'm still having the same issue. It can create the albums and says it's uploading the pictures. The albums show up, but not the photos.

    I'm running Fedora Core 5.
  • ruttrutt Registered Users Posts: 6,511 Major grins
    edited June 8, 2008
    Once again this is broken. It fails to authenticate for me. *Sigh* Sorry this is so fragile, but it's hard to keep up with changes in the API.

    Is there something we can do to make it more robust?

    Dave, thanks in advance for the help.
    If not now, when?
Sign In or Register to comment.