| Reply | « Previous Thread | Next Thread » |
|
My application uses pictures and files (text and pictures) that I would like to keep up-to-date. I would like to put a folder on a web server and give users the possibility to connect and download the whole content: how can I automatically copy all these files to my device folder?
Thanks. |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
|
Quote:
If i understand your problem correctly then what you can do is make a particlular time in your application using timers and then using the urllib module you can retrieve whatever you want to your device and use that in your application. hope this helps you Enjoy Pythoning Gaba88 Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
It's not necessary that download is automatic (I put a menu button with "Update" and it's enough), what I need is to download all the remote files: could it be done just with python or do I need to put some script on the web server? (for example, I created a php script to list all the file into remote folder: am I in the right direction?).
Thanks. |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
If I understood the situation right you could do it simply with Python. Here is an example of how to download a file.
Last edited by bogdan.galiceanu : 2008-10-03 at 09:22.
Reason: Made post clearer
|
|
Ok, that's good, but in this way I guess I need to know the name of my up-to-dated files.
I think my main question is: is it possible to list all files in a remote folder just with python? I supposed something like Code:
webserver = 'http://www.exemple.com/' remote_folder = webserver + 'myfiles/' f_list = os.listdir(remote_folder) for file in f_list: url = remote_folder + file tempfile = "e:\\" + file try: print "Retrieving information..." urllib.urlretrieve(url, tempfile) lock=e32.Ao_lock() content_handler = appuifw.Content_handler(lock.signal) content_handler.open(tempfile) # Wait for the user to exit the image viewer. lock.wait() print "Video viewing finished." except: print "Problems." )If so, I guess I need to retrieve my file list with php or something else. |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Offline
Forum Nokia Champion
|
|
Well, I'm not too knowledgeable when it comes to PHP so I'll suggest something else: have a list containing the names of the files that are to be updated, on the server. Read that list and use the names in it to download all the files you need.
|
|
Quote:
Well, after long time I see something regarding PHP on this Forum ![]() Here is how you can list all files using PHP scripting, you can use this to make a function of your own. Code:
function dirList ($directory)
{
// create an array to hold directory list
$results = array();
// create a handler for the directory
$handler = opendir($directory);
// keep going until all files in directory have been read
while ($file = readdir($handler)) {
// if $file isn't this directory or its parent,
// add it to the results array
if ($file != '.' && $file != '..')
$results[] = $file;
}
// tidy up: close the handler
closedir($handler);
// done!
return $results;
}
Best Regards, Croozeus |
|
Ok, I wrote about php but don't think I'm that good with it!
![]() BTW your script is similar to mine, but I didn't think to put everything in an array! Maybe this is exactly what I needed! Thanks a lot! I'll let you know if it works!! |
|
Quote:
![]() Best Regards, Croozeus |
|
Sorry, but this is my really first attempt to use python with php.
I've called your function, insert my folder and if I try to print output I see my array of values. Then I worked on python so I used Code:
list_file = urllib.urlopen(url_update).read() print list_file I guess I'm doing something wrong. Here are my doubts: PHP: should i print my result or just return it? Python: is the .read() method correct or should I use something else? Sorry if they are silly questions. |
|
Quote:
![]() Quote:
If you use http connection, the below line should do the job. Code:
response=conn.getresponse() Just call the PHP script. read() function should do the job. Best Regards, Croozeus |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
|
Quote:
![]() you are doing nothing wrong with the code because .read() function will only read the url link. What you try is retrieve the link at your phones memory than open it. Hope you got it Enjoy Pythoning Gaba88 Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
Ok, I got it working in some way (not still exactly what I want, but I'm working on it
).Now my other problem is: how do I prevent my app from searching an access point when I'm already connected to one (it's actually asking me for an AP for every file it has to download)? And how I close connection with my connected access point when there is no file to download? I've tried with .close() method but it doesn't work. Thanks for all your support. |
|
Quote:
Use the following function to create a default access point for your application. Code:
def set_accesspoint():
apid = socket.select_access_point()
if appuifw.query(u"Do you want to set this as default access point","query") == True:
f = open('C:\\data\\wc\\apid.txt','w')
f.write(repr(apid))
f.close()
appuifw.note(u"Saved default access point ", "info")
apo = socket.access_point(apid)
socket.set_default_access_point(apo)
Code:
#conn.close() # this will disconnect, but leave gprs active conn.stop() # this will shutdown the gprs connection Code:
conn = iapconnect.Connection() Best Regards, Croozeus |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Application Log Files | kalnyc1 | Installation, Certification and Security | 8 | 2008-10-02 21:39 |
| Update resource files for PhoneBook (N73) | heuven | Installation, Certification and Security | 3 | 2008-04-03 07:57 |
| How to add new files to the application in CodeWarrior? | jennie | Carbide.c++ IDE and plug-ins | 3 | 2007-09-13 08:43 |
| Can a PC suite application visit all the files of phone? | inter_fan | PC Suite API and PC Connectivity SDK | 4 | 2007-08-10 19:12 |
| problem in files downloading in mobile application | KrishnaMegha | Browsing and Mark-ups | 1 | 2007-04-10 22:14 |