Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
173 user(s) are online (157 user(s) are browsing Forums)

Members: 0
Guests: 173

more...

Support us!

Headlines

 
  Register To Post  

Passing arguments to the command line
Quite a regular
Quite a regular


See User information
Is there a maximum length I can pass through on the command line?

eg. whatever.exe "fullpathname.mp3" "fullpathname2.mp3" "fullpathname3.mp3" .... etc ... etc

Also need some help with Python, having a problem with Unescaping single quotes:

The problem is arises in 05 Twilight Zone - after 7 that is two single quotation marks next to each other.


"SMBFS5:itunes/iTunes Media/Music/2 Unlimited/The Complete History/04 Faces [Radio Edit].mp3" "SMBFS5:itunes/iTunes Media/Music/2 Unlimited/The Complete History/05 Twilight Zone [7'' Vocal].mp3" "SMBFS5:itunes/iTunes Media/Music/2 Unlimited/The Complete History/06 Maximum Overdrive.mp3" "SMBFS5:itunes/iTunes Media/Music/2 Unlimited/The Complete History/08 Get Ready For This [Radio Edit].mp3" "SMBFS5:itunes/iTunes Media/Music/2 Unlimited/The Complete History/07 Let The Beat Control Your Body [Airplay Edit].mp3"
Traceback (most recent call last):
File "python:scripts/jack_getalbumartwork.py", line 10, in
file = File(filename)
File "PYTHON:Lib/site-packages/mutagen/__init__.py", line 203, in File
fileobj = file(filename, "rb")
IOError: [Errno 20] Not a directory: ''

Original thread on AW:

http://amigaworld.net/modules/newbb/v ... p?topic_id=33771&forum=17

Go to top
Re: Passing arguments to the command line
Quite a regular
Quite a regular


See User information
I am not familiar with Python myself, but here is the script I have created, I think I need some unescaping going on between line 9 and 10.

(Mutagen Library / Dependacies - http://code.google.com/p/quodlibet/downloads/list)

from __future__ import with_statement
from mutagen import File

import sys, os

value = 1
for arg in sys.argv:
<Tab> if arg != "python:scripts/jack_getalbumartwork.py":
<Tab><Tab> filename = sys.argv[value]

<Tab><Tab> file = File(filename)
<Tab><Tab> try:
<Tab><Tab><Tab> if not os.path.exists('jack:JackTunes Album Artwork/' + os.path.basename(filename) + '.jpg'):
<Tab><Tab><Tab><Tab> artwork = file.tags['APIC:'].data # access APIC frame and grab the image
<Tab><Tab><Tab><Tab> with open('jack:JackTunes Album Artwork/' + os.path.basename(filename) + '.jpg', 'wb') as img:
<Tab><Tab><Tab><Tab><Tab> img.write(artwork) # write artwork to new image'
<Tab><Tab> except:
<Tab><Tab><Tab> null = 0

<Tab><Tab> value += 1

Go to top
Re: Passing arguments to the command line
Quite a regular
Quite a regular


See User information
Actually - just worked it out - its not the Python script after all - its fine!

BUT still what is the maximum length of a string that I can pass to the command line? Is it unlimited?

Is it okay to pass 9000+ filenames to a program running on the command line or should I split it up?

Go to top
Re: Passing arguments to the command line
Supreme Council
Supreme Council


See User information
The standard C library startup code defines the main() entry point of a program having the following prototype:

int main( int argc, char** argv )

Basically, this means that the amount of arguments is limited to, at least, a 16bit number (0 -> 65535).

And further up the chain the real entry point used by CreateNewProc is defined as _start( STRPTR args, int32 arglen, ...), so this implies the string containing the arguments be limited to a signed long word (0 -> 2147483648). This equates to a string no longer than 2GB. Adding thousands of arguments into a string, each with a path of 512bytes, means a theoretical limit of almost 4.2 million arguments. Given that this is way beyond the 16bit argument count in main(), I'd say we found the biggest limitation.

Whether there are any other limitations impposed by DOS itself, I'm not sure, it's not something I've ever looked into. I would assume parsing 9000+ parameters would be very slow, especially if the program is using ReadArgs().

You may be better off to call the program once for each entry, but only a timed test of both situations will really tell you.

Simon

Comments made in any post are personal opinion, and are in no-way representative of any commercial entity unless specifically stated as such.
----
http://codebench.co.uk
Go to top
Re: Passing arguments to the command line
Quite a regular
Quite a regular


See User information
Thanks Rigo.

Seems I need to investigate a little further anyhow as I am taking the wrong approach -iTunes doesn't embed artwork by default it stores it in a series of folders.

There is a Python module to decipher itc files, but first I need to decipher the folder structure.

<key>Library Persistent ID</key><string>76710B0D0E49CFBE</string>

Thats the root folder - well not quite there is a Cache and Download folder above this :S

Every song has its own ID:

<key>Persistent ID</key><string>75F7324F2E407D63</string>

So we have 76710B0D0E49CFBE-75F7324F2E407D63.itc.

But there are 3 folders between these two - typically like this 15/15/13 - looking at the XML i have no idea where this obtained from :S

http://www.sffjunkie.co.uk/python-itc.html

Go to top
Re: Passing arguments to the command line
Quite a regular
Quite a regular


See User information
I wonder if its stored in the ID3 tags... hmmm

The way I am doing atm is not very efficient, I've left Jack alone for the last 30 minutes and its only up to C in the alphabet. ^^

Go to top
Re: Passing arguments to the command line
Amigans Defender
Amigans Defender


See User information
@rigo

Quote:
Whether there are any other limitations impposed by DOS itself, I'm not sure, it's not something I've ever looked into.


The Shell has a much shorter limit (not sure what it is, maybe 1K), which can be worked around by creating a script with the command line in and executing that.

Not sure if the Shell supports concatenation of multiple lines.

Go to top
Re: Passing arguments to the command line
Quite a regular
Quite a regular


See User information
@Rigo

I set it so that it limits command line output to no more than 65534 characters.. worked flawlessly

@all

Thought I'd share a screenie showing what I have been working on this weekend - JackTunes.

Requirements: A Mac (Windows Support should be easy to add later), an Amiga, a Samba network between the two.

Software: Latest AmigaOS, Python

Screenshot showing preliminary work - Grabbing Cover Artwork from iTunes across the network

http://www.flickr.com/photos/61283734 ... 5800420593/in/photostream

Left Window: Shows raw output coming from Python to convert iTunes cover artwork.

Right Window: The local artwork drawer containing images converted from ict to png.

Middle: Selection of Windows showing cover artwork.

All track information is also gathered using Python.

As a benchmark, I have over 9000+ songs in my iTunes. Using Jack and Python it took less than 5 minutes to gather all album artwork across the network!

Enjoy!

Go to top
Re: Passing arguments to the command line
Just popping in
Just popping in


See User information

Go to top
Re: Passing arguments to the command line
Just can't stay away
Just can't stay away


See User information
by djrikki
Also need some help with Python, having a problem with Unescaping single quotes...

It's not about 'unescaping quotes', it;s about Python Dos ways and formatted List files.
You need to read Chapter 3.14:Lists and Chapter 5:Data Structures, in Python - Docs 2.5/tut/tut.html

Actually - just worked it out - its not the Python script after all - its fine!
I haven't figured what your script is doing. I don't see any definitions...

There is a Python module to decipher itc files, but first I need to decipher the folder structure.
<key>Library Persistent ID</key><string>76710B0D0E49CFBE</string>

That's a typical Python 'Dictionary' format.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project