Trouble passing arguments - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Trouble passing arguments (/thread-6277.html) |
Trouble passing arguments - underoathed - Nov-13-2017 When I call the functions and go to pass arguments for the functions (specifically for download_clips and download_clip) I get an error. I'm unsure what is supposed to go in their. I've tried multiple arguments but I can't seem to get the correct one. Also, for download_clip can I put multiple clips in there? Is there a way to have download_clip download all .mov files? def download_clip(clip): url = "http://10.1.1.27/media/" + clip print url def download_clips(response): values = response.split(":") i = 0 for word in values: i += 1 if(word.find('clipname') > -1): clip = values[i].split(',')[0].translate(string.maketrans("",""), '[]{} \,\"\" ') if not os.path.exists(clip): print "Downloading clip: " + clip else: f = urllib.urlopen("http://10.1.1.27/config?action=set¶mid=eParamID_MediaState&value=0") print "No new clips found"
RE: Trouble passing arguments - AceScottie - Nov-13-2017 how are you calling the download_clips(response) function ? RE: Trouble passing arguments - underoathed - Nov-13-2017 I've modified the code since this was put up. Here is the updated code. It works. However I need to be able to download all .mov files to a directory. Can you assist with this? import urllib, string, os def is_download_allowed(): f = urllib.urlopen("http://10.1.1.27/config?action=get¶mid=eParamID_MediaState") response = f.read() if (response.find('"value":"1"') > -1): return True f = urllib.urlopen("http://10.1.1.27/config?action=set¶mid=eParamID_MediaState&value=1") def download_clip(clip): url = "http://10.1.1.27/media/" + clip print url #os.system("curl --output " + clip + " " + url); def download_clips(): i = 0 response = "" values = response.split(":") for word in values: i += 1 if(word.find('clipname') > -1): clip = values[i].split(',')[0].translate(string.maketrans("",""), '[]{} \,\"\" ') if not os.path.exists(clip): print "Downloading clip: " + clip else: f = urllib.urlopen("http://10.1.1.27/config?action=set¶mid=eParamID_MediaState&value=0") print "No new clips found" def is_download_not_allowed(): f = urllib.urlopen("http://10.1.1.27/config?action=get¶mid=eParamID_MediaState") response = f.read() if (response.find('"value":"-1"') > 1): return True f = urllib.urlopen("http://10.1.1.27/config?action=set¶mid=eParamID_MediaState&value=0") is_download_allowed() download_clip('C1ATK26') download_clips() is_download_not_allowed() |