Anonymous avatar Anonymous committed eb37714

PiCloud article source codes

Comments (0)

Files changed (6)

picloud_article/client1.c

+/* This part of the client invokes the REST API of
+   PiCloud and retrieves the Job ID
+   http://docs.picloud.com/rest.html#invoking-functions
+*/
+
+#include <stdio.h>
+#include <curl/curl.h>
+
+int main(void)
+{
+  CURL *curl;
+
+  /* Make sure you set this appropriately*/
+  char *url="https://api.picloud.com/r/3222/square_func/";
+  CURLcode res;
+  
+  curl = curl_easy_init();
+  if(curl) {
+    /* First set the URL that is about to receive our POST. This URL can
+       just as well be a https:// URL if that is what should receive the
+       data. */
+    curl_easy_setopt(curl, CURLOPT_URL, url);
+    /* Specify the user/pass */
+    curl_easy_setopt(curl,CURLOPT_USERPWD,"3244:8823b533ef41975505c8dbe46a2f85b930428944");
+    
+    /* Now specify the POST data */
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "x=5");
+    
+    /* For HTTPS */
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
+
+    /* Perform the request, res will get the return code */
+    res = curl_easy_perform(curl);
+    printf("\nResult of Operation:: %d\n", res);
+
+    /* always cleanup */
+    curl_easy_cleanup(curl);
+  }
+  return 0;
+}

picloud_article/client2.c

+/* This part of the client retrieves the result given the
+   job ID as the argument*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <curl/curl.h>
+
+int main(int argc, char *argv[])
+{
+  CURL *curl;
+  char url[80];
+  CURLcode res;
+
+  if (argc==1)
+    {
+      printf("Usage: ./client2 <jid>\n");
+      exit(0);
+    }
+
+  
+  strcpy(url,"https://api.picloud.com/job/result/?jid=");
+  strcat(url,argv[1]);
+
+  
+
+  curl = curl_easy_init();
+  if(curl) {
+    /* First set the URL that is about to receive our POST. This URL can
+       just as well be a https:// URL if that is what should receive the
+       data. */
+    curl_easy_setopt(curl, CURLOPT_URL, url);
+    
+    /* Specify the user/pass */
+    curl_easy_setopt(curl,CURLOPT_USERPWD,"3244:8823b533ef41975505c8dbe46a2f85b930428944");
+    
+    /* for HTTPS */
+    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
+    
+    /* Perform the request, res will get the return code */
+    res = curl_easy_perform(curl);
+    printf("\nResult of Operation:: %d\n", res);
+
+    /* always cleanup */
+    curl_easy_cleanup(curl);
+  }
+  return 0;
+}

picloud_article/demo.py

+import numpy
+
+def sort_num(num):
+    sort_num = numpy.sort(num)
+    return sort_num

picloud_article/filedemo.py

+import cloud
+
+def savedata():
+    f=open('data.txt','w')
+    f.write('This is a line of text')
+    f.close()
+    
+    cloud.files.put('data.txt')

picloud_article/mapdemo.py

+import numpy
+
+def vol_cylinder(r,h):
+    return numpy.pi*r*r*h

picloud_article/publish_square.py

+def square(x):
+    """Returns square of a number"""
+    print 'Squaring %d' % x
+    return x*x
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.