# Uploading one numeric value from X2 to iDigi.

**URL:** <https://forums.digi.com/t/uploading-one-numeric-value-from-x2-to-idigi/2806>\
**Category:** Python\
**Created:** [August 23, 2011, 11:05pm UTC](https://forums.digi.com/t/uploading-one-numeric-value-from-x2-to-idigi/2806 "2011-08-23T23:05:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![massimo.marcon](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@massimo.marcon](https://forums.digi.com/u/massimo.marcon)\
**Post date:** [August 23, 2011, 11:05pm UTC](https://forums.digi.com/t/uploading-one-numeric-value-from-x2-to-idigi/2806/1 "2011-08-23T23:05:48Z")

</div>

Hi,  
I have one X2 that is registered and connected to iDigi.  
The goal I want to achieve is to upload one numeric value from X2 to iDigi.  
I’m running the following Digi example but the message it returns is :“Uploading device\_stats0.xml to iDigi server…  
Failed upload.  
Please, wait 5 minutes…”

What I’m missing?Is there a better way/example to achieve this goal?

Thanks

* * *

“”"  
iDigi stats example

```
THIS EXAMPLE WILL NOT FUNCTION EXCEPT ON DIGI DEVICES

This example sends device statistics to iDigi server every 5 minutes. 
They are stored into collection called "device_stats" and will send
a maximum of 10 files.

```

“”"

# imports

import sys, os  
import time

# import the rci module to get access to the process\_request method

import rci  
import cStringIO

# import this module to push up data files to the iDigi server the device

# belongs to

# from libs import idigi\_data

sys.path.append(“WEB/python/libs.zip”)

# constants

collection = “device\_stats”  
counter = 0  
max\_files = 10

while True:  
# this is the rci request that will return device statistics  
request = ’   
’  
# response will store the response from the rci request  
response = rci.process\_request(request)

```
# build XML string of the response
xml = cStringIO.StringIO()
xml.write("")
xml.write("")
xml.write(response)
xml.write("")
data = xml.getvalue()
xml.close()
# build file name
filename = "device_stats" + str(counter) + ".xml"
# push XML response to iDigi
print "Uploading %s to iDigi server..." % filename

try:
    success, error, errmsg= idigi_data.send_idigi_data (data, filename, \
                                                    collection,
                                                        secure=False)
    # validate upload
    if success:
        print "Successful upload.

```

"  
else:  
print "Failed upload.  
"  
except:  
print "Failed upload.  
"

```
# increase counter
counter += 1
if counter == max_files:
    counter = 0

# wait 5 minutes
print "Please, wait 5 minutes...

```

"  
time.sleep(300)

---

<div class="post-metadata">

**Author:** ![massimo.marcon](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@massimo.marcon](https://forums.digi.com/u/massimo.marcon)\
**Post date:** [September 2, 2011, 8:16am UTC](https://forums.digi.com/t/uploading-one-numeric-value-from-x2-to-idigi/2806/2 "2011-09-02T08:16:41Z")

</div>

Hello all,  
many days haave been passed by and I’m not receiving any response to this thread.

Why?  
Is there a problem?

Regards

Massimo

---

<div class="post-metadata">

**Author:** ![shahrj1988](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@shahrj1988](https://forums.digi.com/u/shahrj1988)\
**Post date:** [September 4, 2011, 4:47pm UTC](https://forums.digi.com/t/uploading-one-numeric-value-from-x2-to-idigi/2806/3 "2011-09-04T16:47:28Z")

</div>

Hi,

Are you making this project from ESP for python? If yes, then check, whether in your project in libs, idigi\_data.py is there?

And remove this sentence from your code, as dpdsrv.py (auto generated python script while running the project from ESP for python) would take care of it.

sys.path.append(“WEB/python/libs.zip”)

The zip file name would be \_projectname.zip

I hope this will help.
