Ejemplo n.º 1
0
    def get(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        #self.response.out.write('posted!')
        # Den Namen des zu löschen Buckets holen
        bucketname = self.request.get('bucket')

        # Den Usernamen erfahren
        username = users.get_current_user()

        # Mit S3 verbinden
        conn_s3 = logins3(username)
        try:
            # Versuch den Bucket zu löschen
            conn_s3.delete_bucket(bucketname)
        except:
            fehlermeldung = "109"
            # Wenn es nicht klappt...
            self.redirect('/s3?mobile=' + str(mobile) + '&message=' +
                          fehlermeldung)
        else:
            fehlermeldung = "110"
            # Wenn es geklappt hat...
            self.redirect('/s3?mobile=' + str(mobile) + '&message=' +
                          fehlermeldung)
Ejemplo n.º 2
0
    def post(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        # Zum Testen, ob "post" funktioniert hat
        # self.response.out.write('posted!')
        keyname = self.request.get('keyname')
        bucketname = self.request.get('bucketname')
        canned_acl = self.request.get('canned_acl')
        typ = self.request.get('typ')
        directory = self.request.get('dir')

        # Den Usernamen erfahren
        username = users.get_current_user()

        # Mit S3 verbinden
        conn_s3 = logins3(username)
        # Mit dem Bucket verbinden
        bucket_instance = conn_s3.get_bucket(bucketname)

        try:
            # Access Control List (ACL) setzen
            bucket_instance.set_acl(canned_acl, key_name=keyname)
        except EC2ResponseError:
            # Wenn es nicht klappt...
            fehlermeldung = "119"
            if typ == "pur":
                self.redirect('/bucket_inhalt_pure?mobile=' + str(mobile) +
                              '&bucket=' + bucketname + '&message=' +
                              fehlermeldung)
            else:
                if directory == "/":
                    self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                                  '&bucket=' + bucketname + '&message=' +
                                  fehlermeldung)
                else:
                    directory = str(directory)[:-1]
                    self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                                  '&bucket=' + bucketname + '&dir=' +
                                  directory + '&message=' + fehlermeldung)
        else:
            # Wenn es geklappt hat...
            fehlermeldung = "118"
            if typ == "pur":
                self.redirect('/bucket_inhalt_pure?mobile=' + str(mobile) +
                              '&bucket=' + bucketname + '&message=' +
                              fehlermeldung)
            else:
                if directory == "/":
                    self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                                  '&bucket=' + bucketname + '&message=' +
                                  fehlermeldung)
                else:
                    directory = str(directory)[:-1]
                    self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                                  '&bucket=' + bucketname + '&dir=' +
                                  directory + '&message=' + fehlermeldung)
    def get(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        # Den Usernamen erfahren
        username = users.get_current_user()
        # Den Namen des Buckets erfahren
        bucketname = self.request.get('bucket')
        # Die S3-Ansicht (pur oder Komfort) erfahren
        s3_ansicht = self.request.get('s3_ansicht')

        conn_region, regionname = login(username)

        # Mit S3 verbinden
        conn_s3 = logins3(username)
        bucket_instance = conn_s3.get_bucket(bucketname)

        liste_keys = bucket_instance.get_all_keys()
        # Anzahl der Keys in der Liste
        laenge_liste_keys = len(liste_keys)

        # Wenn wir in einer Eucalyputs-Infrastruktur sind, dann muss dieser
        # dämliche None-Eintrag weg
        if regionname != "Amazon":
            liste_keys2 = []
            for i in range(laenge_liste_keys):
                if str(liste_keys[i].name) != 'None':
                    liste_keys2.append(liste_keys[i])
            laenge_liste_keys2 = len(liste_keys2)
            laenge_liste_keys = laenge_liste_keys2
            liste_keys = liste_keys2

        try:
            for i in range(laenge_liste_keys):
                # Versuch den Key zu löschen
                liste_keys[i].delete()
        except:
            # Wenn es nicht klappt...
            fehlermeldung = "121"
            self.redirect('/bucket_inhalt_pure?mobile=' + str(mobile) +
                          '&bucket=' + bucketname + '&message=' +
                          fehlermeldung)
        else:
            # Wenn es geklappt hat...
            fehlermeldung = "120"
            self.redirect('/bucket_inhalt_pure?mobile=' + str(mobile) +
                          '&bucket=' + bucketname + '&message=' +
                          fehlermeldung)
Ejemplo n.º 4
0
    def post(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        # Zum Testen, ob "post" funktioniert hat
        # self.response.out.write('posted!')
        keyname    = self.request.get('keyname')
        bucketname = self.request.get('bucketname')
        canned_acl = self.request.get('canned_acl')
        typ        = self.request.get('typ')
        directory  = self.request.get('dir')

        # Den Usernamen erfahren
        username = users.get_current_user()

        # Mit S3 verbinden
        conn_s3 = logins3(username)
        # Mit dem Bucket verbinden
        bucket_instance = conn_s3.get_bucket(bucketname)

        try:
          # Access Control List (ACL) setzen
          bucket_instance.set_acl(canned_acl, key_name=keyname)
        except EC2ResponseError:
          # Wenn es nicht klappt...
          fehlermeldung = "119"
          if typ == "pur":
            self.redirect('/bucket_inhalt_pure?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung)
          else:
            if directory == "/":
              self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung)
            else:
              directory = str(directory)[:-1]
              self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&dir='+directory+'&message='+fehlermeldung)
        else:
          # Wenn es geklappt hat...
          fehlermeldung = "118"
          if typ == "pur":
            self.redirect('/bucket_inhalt_pure?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung)
          else:
            if directory == "/":
              self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung)
            else:
              directory = str(directory)[:-1]
              self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&dir='+directory+'&message='+fehlermeldung)
    def get(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        # Den Usernamen erfahren
        username = users.get_current_user()
        # Den Namen des Buckets erfahren
        bucketname = self.request.get('bucket')
        # Die S3-Ansicht (pur oder Komfort) erfahren
        s3_ansicht = self.request.get('s3_ansicht')

        conn_region, regionname = login(username)

        # Mit S3 verbinden
        conn_s3 = logins3(username)
        bucket_instance = conn_s3.get_bucket(bucketname)

        liste_keys = bucket_instance.get_all_keys()
        # Anzahl der Keys in der Liste
        laenge_liste_keys = len(liste_keys)

        # Wenn wir in einer Eucalyputs-Infrastruktur sind, dann muss dieser
        # dämliche None-Eintrag weg
        if regionname != "Amazon":
          liste_keys2 = []
          for i in range(laenge_liste_keys):
            if str(liste_keys[i].name) != 'None':
              liste_keys2.append(liste_keys[i])
          laenge_liste_keys2 = len(liste_keys2)
          laenge_liste_keys = laenge_liste_keys2
          liste_keys = liste_keys2


        try:
          for i in range(laenge_liste_keys):
            # Versuch den Key zu löschen
            liste_keys[i].delete()
        except:
          # Wenn es nicht klappt...
          fehlermeldung = "121"
          self.redirect('/bucket_inhalt_pure?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung)
        else:
          # Wenn es geklappt hat...
          fehlermeldung = "120"
          self.redirect('/bucket_inhalt_pure?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung)
Ejemplo n.º 6
0
    def get(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        #self.response.out.write('posted!')
        # Den Namen des zu löschen Buckets holen
        bucketname = self.request.get('bucket')

        # Den Usernamen erfahren
        username = users.get_current_user()

        # Mit S3 verbinden
        conn_s3 = logins3(username)
        try:
          # Versuch den Bucket zu löschen
          conn_s3.delete_bucket(bucketname)
        except:
          fehlermeldung = "109"
          # Wenn es nicht klappt...
          self.redirect('/s3?mobile='+str(mobile)+'&message='+fehlermeldung)
        else:
          fehlermeldung = "110"
          # Wenn es geklappt hat...
          self.redirect('/s3?mobile='+str(mobile)+'&message='+fehlermeldung)
Ejemplo n.º 7
0
    def post(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        # self.response.out.write('posted!')
        # Die Eingabe aus dem Formular holen
        neuerbucketname = self.request.get('bucketname')

        # Den Usernamen erfahren
        username = users.get_current_user()

        if neuerbucketname == "":
            # Testen ob ein Name für den neuen key angegeben wurde
            # Wenn kein Name angegeben wurde, kann kein Key angelegt werden
            #fehlermeldung = "Sie haben keine Namen angegeben"
            fehlermeldung = "92"
            self.redirect('/s3?mobile=' + str(mobile) + '&message=' +
                          fehlermeldung)
        elif re.search(r'[^\-.a-zA-Z0-9]', neuerbucketname) != None:
            # Testen ob der Name für den neuen key nicht erlaubte Zeichen enthält
            fehlermeldung = "106"
            self.redirect('/s3?mobile=' + str(mobile) + '&message=' +
                          fehlermeldung)
        else:
            # Mit S3 verbinden
            conn_s3 = logins3(username)
            try:
                # Liste der Buckets
                liste_buckets = conn_s3.get_all_buckets()
            except:
                # Wenn es nicht klappt...
                fehlermeldung = "107"
                self.redirect('/s3?mobile=' + str(mobile) + '&message=' +
                              fehlermeldung)
            else:
                # Wenn es geklappt hat...
                # Variable erzeugen zum Erfassen, ob der neue Bucket schon existiert
                laenge_liste_buckets = len(liste_buckets)

                # Variable erzeugen zum Erfassen, ob der neue Bucket schon existiert
                schon_vorhanden = 0
                for i in range(laenge_liste_buckets):
                    # Bucket-Namen in einen String umwandeln
                    vergleich = str(liste_buckets[i].name)
                    # Vergleichen
                    if vergleich == neuerbucketname:
                        # Bucket-Name existiert schon!
                        schon_vorhanden = 1

                if schon_vorhanden == 0:
                    # Wenn man noch keinen Bucket mit dem eingegebenen Namen besitzt...
                    try:
                        # Versuch den Bucket anzulegen
                        conn_s3.create_bucket(neuerbucketname)
                    except:
                        fehlermeldung = "107"
                        # Wenn es nicht klappt...
                        self.redirect('/s3?mobile=' + str(mobile) +
                                      '&message=' + fehlermeldung)
                    else:
                        fehlermeldung = "105"
                        # Wenn es geklappt hat...
                        self.redirect('/s3?mobile=' + str(mobile) +
                                      '&message=' + fehlermeldung)
                else:
                    # Wenn man schon einen Bucket mit dem eingegeben Namen hat...
                    fehlermeldung = "108"
                    self.redirect('/s3?mobile=' + str(mobile) + '&message=' +
                                  fehlermeldung)
    def post(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        #self.response.out.write('posted!')
        # Die Eingabe aus dem Formular holen
        verzeichnisname = self.request.get('verzeichnisname') 
        # Den Bucketnamen aus dem Formular holen
        bucketname = self.request.get('bucket')
        # Das Verzeichnis aus dem Formular holen
        directory = self.request.get('dir')

        # Den Usernamen erfahren
        username = users.get_current_user()

        if verzeichnisname == "":
          # Testen ob ein Name für den neuen key angegeben wurde
          # Wenn kein Name angegeben wurde, kann kein Key angelegt werden
          #fehlermeldung = "Sie haben keine Namen angegeben"
          fehlermeldung = "113"
          if directory == "/":
            self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung)
          else:
            # Den Slash am Ende des Verzeichnisses entfernen
            directory = str(directory[:-1])
            self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung+'&dir='+directory)
        elif re.search(r'[^\-_a-zA-Z0-9]', verzeichnisname) != None:
          # Testen ob der Name für den neuen key nicht erlaubte Zeichen enthält
          fehlermeldung = "114"
          if directory == "/":
            self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung)
          else:
            # Den Slash am Ende des Verzeichnisses entfernen
            directory = str(directory[:-1])
            self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung+'&dir='+directory)
        else:
          # Mit S3 verbinden
          conn_s3 = logins3(username) 
          # Mit dem Bucket verbinden
          bucket_instance = conn_s3.get_bucket(bucketname)
          # Liste der Keys im Bucket
          liste_keys = bucket_instance.get_all_keys()
          # Anzahl der Keys in der Liste
          laenge_liste_keys = len(liste_keys)

          verzeichnisname = verzeichnisname+'_$folder$'

          # Variable erzeugen zum Erfassen, ob das neue Verzeichnis schon existiert
          schon_vorhanden = 0
          for i in range(laenge_liste_keys):
            # Key-Namen in einen String umwandeln
            vergleich = str(liste_keys[i].name)
            # Vergleichen
            if vergleich == verzeichnisname:
              # Verzeichnis-Name existiert schon!
              schon_vorhanden = 1
              fehlermeldung = "117"
              if directory == "/":
                self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung)
              else:
                # Den Slash am Ende des Verzeichnisses entfernen
                directory = str(directory[:-1])
                self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung+'&dir='+directory)

          # Wenn man noch kein Verzeichnis mit dem eingegebenen Namen besitzt... 
          if schon_vorhanden == 0:
            try:
              # Versuch das Verzeichnis anzulegen
              # Mit dem Bucket sind wir schon verbunden über die Zeile
              # bucket_instance = conn_s3.get_bucket(bucketname)
              if directory == '/':
                key = bucket_instance.new_key(verzeichnisname)
                key.set_contents_from_string('')
              else:
                verzeichnisname = directory + verzeichnisname
                key = bucket_instance.new_key(verzeichnisname)
                key.set_contents_from_string('')
            except:
              # Wenn es nicht klappt...
              fehlermeldung = "116"
              if directory == "/":
                self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung)
              else:
                # Den Slash am Ende des Verzeichnisses entfernen
                directory = str(directory[:-1])
                self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung+'&dir='+directory)
            else:
              # Wenn es geklappt hat...
              fehlermeldung = "115"
              if directory == "/":
                self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung)
              else:
                # Den Slash am Ende des Verzeichnisses entfernen
                directory = str(directory[:-1])
                self.redirect('/bucket_inhalt?mobile='+str(mobile)+'&bucket='+bucketname+'&message='+fehlermeldung+'&dir='+directory)
                
Ejemplo n.º 9
0
    def get(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        # self.response.out.write('posted!')
        # Den Usernamen erfahren
        username = users.get_current_user()
        if not username:
          self.redirect('/')
        # Eventuell vorhande Fehlermeldung holen
        message = self.request.get('message')

        # Nachsehen, ob eine Region/Zone ausgewählte wurde
        aktivezone = db.GqlQuery("SELECT * FROM KoalaCloudDatenbankAktiveZone WHERE user = :username_db", username_db=username)
        results = aktivezone.fetch(100)

        if not results:
          self.redirect('/')
        else:
          # Nachsehen, ob eine Sprache ausgewählte wurde und wenn ja, welche Sprache
          sprache = aktuelle_sprache(username)
          navigations_bar = navigations_bar_funktion(sprache,mobile)

          url = users.create_logout_url(self.request.uri).replace('&', '&').replace('&', '&')
          url_linktext = 'Logout'

          conn_region, regionname = login(username)
          zone_amazon = amazon_region(username)

          zonen_liste = zonen_liste_funktion(username,sprache,mobile)

          if sprache != "de":
            sprache = "en"

          input_error_message = error_messages.get(message, {}).get(sprache)

          # Wenn keine Fehlermeldung gefunden wird, ist das Ergebnis "None"
          if input_error_message == None:
            input_error_message = ""

          # Wenn die Nachricht grün formatiert werden soll...
          if message in ("105", "110"):
            # wird sie hier, in der Hilfsfunktion grün formatiert
            input_error_message = format_error_message_green(input_error_message)
          # Ansonsten wird die Nachricht rot formatiert
          elif message in ("92", "106", "107", "108", "109"):
            input_error_message = format_error_message_red(input_error_message)
          else:
            input_error_message = ""

          # Mit S3 verbinden
          conn_s3 = logins3(username)

          try:
            # Liste der Buckets
            liste_buckets = conn_s3.get_all_buckets()
          except:
            # Wenn es nicht klappt...
            if sprache == "de":
              bucketstabelle = '<font color="red">Es ist zu einem Fehler gekommen</font>'
            else:
              bucketstabelle = '<font color="red">An error occured</font>'
          else:
            # Wenn es geklappt hat...
            # Anzahl der Elemente in der Liste
            laenge_liste_buckets = len(liste_buckets)

            if laenge_liste_buckets == 0:
              if sprache == "de":
                bucketstabelle = 'Es sind keine Buckets in der Region vorhanden.'
              else:
                bucketstabelle = 'Still no buckets exist inside this region.'
            else:
              
              if mobile == "true":
                # Mobile version
                
                bucketstabelle = ''
                bucketstabelle += '<table border="0" cellspacing="0" cellpadding="5">'
                for i in range(laenge_liste_buckets):
                    bucketstabelle += '<tr>'
                    bucketstabelle += '<td align="left">'
                    bucketstabelle += '<a href="/bucketentfernen?bucket='
                    bucketstabelle += str(liste_buckets[i].name)
                    bucketstabelle += "&amp;mobile="
                    bucketstabelle += str(mobile)
                    if sprache == "de":
                      bucketstabelle += '" title="Bucket l&ouml;schen"><img src="bilder/delete.png" width="16" height="16" border="0" alt="Bucket l&ouml;schen"></a>'
                    else:
                      bucketstabelle += '" title="erase bucket"><img src="bilder/delete.png" width="16" height="16" border="0" alt="erase bucket"></a>'
                    bucketstabelle += '</td>'
                    bucketstabelle += '<td colspan="4" align="left">'+str(liste_buckets[i].name)+'</td>'
                    bucketstabelle += '</tr>'
                    bucketstabelle += '<tr>'
                    bucketstabelle += '<td>&nbsp;</td>'
                    if sprache == "de":
                      bucketstabelle += '<td align="right"><b>Reines S3:</b></td>'
                    else:
                      bucketstabelle += '<td align="right"><b>pure S3:</b></td>'
                    bucketstabelle += '<td align="left">'
                    bucketstabelle += '<a href="/bucket_inhalt_pure?bucket='
                    bucketstabelle += str(liste_buckets[i].name)
                    bucketstabelle += "&amp;mobile="
                    bucketstabelle += str(mobile)
                    if sprache == "de":
                      bucketstabelle += '" title="Bucket einsehen (reine S3-Darstellung)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                    else:
                      bucketstabelle += '" title="List content of this bucket (pure S3)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                    bucketstabelle += '</td>'
                    if sprache == "de":
                      bucketstabelle += '<td align="right"><b>Komfort S3:</b></td>'
                    else:
                      bucketstabelle += '<td align="right"><b>comfort S3:</b></td>'
                    bucketstabelle += '<td align="left">'
                    bucketstabelle += '<a href="/bucket_inhalt?bucket='
                    bucketstabelle += str(liste_buckets[i].name)
                    bucketstabelle += "&amp;mobile="
                    bucketstabelle += str(mobile)
                    if sprache == "de":
                      bucketstabelle += '" title="Bucket einsehen (Komfort-Darstellung)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                    else:
                      bucketstabelle += '" title="List content of this bucket (S3 with more comfort)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                    bucketstabelle += '</td>'
                    bucketstabelle += '</tr>'
                bucketstabelle += '</table>'
              
              else:
                # Not the mobile version
                
                bucketstabelle = ''
                bucketstabelle += '<table border="0" cellspacing="0" cellpadding="5">'
                bucketstabelle += '<tr>'
                bucketstabelle += '<th>&nbsp;</th>'
                bucketstabelle += '<th align="left">Buckets</th>'
                if sprache == "de":
                  bucketstabelle += '<th>Reine S3-Darstellung</th>'
                  bucketstabelle += '<th>Komfort-Darstellung</th>'
                else:
                  bucketstabelle += '<th>Pure S3</th>'
                  bucketstabelle += '<th>S3 with more comfort</th>'
                bucketstabelle += '</tr>'
                for i in range(laenge_liste_buckets):
                    bucketstabelle += '<tr>'
                    bucketstabelle += '<td>'
                    bucketstabelle += '<a href="/bucketentfernen?bucket='
                    bucketstabelle += str(liste_buckets[i].name)
                    bucketstabelle += "&amp;mobile="
                    bucketstabelle += str(mobile)
                    if sprache == "de":
                      bucketstabelle += '" title="Bucket l&ouml;schen"><img src="bilder/delete.png" width="16" height="16" border="0" alt="Bucket l&ouml;schen"></a>'
                    else:
                      bucketstabelle += '" title="erase bucket"><img src="bilder/delete.png" width="16" height="16" border="0" alt="erase bucket"></a>'
                    bucketstabelle += '</td>'
                    bucketstabelle += '<td>'+str(liste_buckets[i].name)+'</td>'
                    bucketstabelle += '<td align="center">'
                    bucketstabelle += '<a href="/bucket_inhalt_pure?bucket='
                    bucketstabelle += str(liste_buckets[i].name)
                    if sprache == "de":
                      bucketstabelle += '" title="Bucket einsehen (reine S3-Darstellung)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                    else:
                      bucketstabelle += '" title="List content of this bucket (pure S3)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                    bucketstabelle += '</td>'
                    bucketstabelle += '<td align="center">'
                    bucketstabelle += '<a href="/bucket_inhalt?bucket='
                    bucketstabelle += str(liste_buckets[i].name)
                    if sprache == "de":
                      bucketstabelle += '" title="Bucket einsehen (Komfort-Darstellung)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                    else:
                      bucketstabelle += '" title="List content of this bucket (S3 with more comfort)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                    bucketstabelle += '</td>'
                    bucketstabelle += '</tr>'
                bucketstabelle += '</table>'

          path = '&amp;path=s3&amp;mobile='+mobile

          template_values = {
          'navigations_bar': navigations_bar,
          'url': url,
          'url_linktext': url_linktext,
          'zone': regionname,
          'zone_amazon': zone_amazon,
          'zonen_liste': zonen_liste,
          'bucketstabelle': bucketstabelle,
          'input_error_message': input_error_message,
          'mobile': mobile,
          'path': path,
          }

          if mobile == "true":
              path = os.path.join(os.path.dirname(__file__), "../templates/mobile", sprache, "s3.html")
          else:
              path = os.path.join(os.path.dirname(__file__), "../templates", sprache, "s3.html")
          self.response.out.write(template.render(path,template_values))
Ejemplo n.º 10
0
    def get(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        # self.response.out.write('posted!')
        # Den Usernamen erfahren
        username = users.get_current_user()
        if not username:
            self.redirect('/')
        # Eventuell vorhande Fehlermeldung holen
        message = self.request.get('message')

        # Nachsehen, ob eine Region/Zone ausgewählte wurde
        aktivezone = db.GqlQuery(
            "SELECT * FROM KoalaCloudDatenbankAktiveZone WHERE user = :username_db",
            username_db=username)
        results = aktivezone.fetch(100)

        if not results:
            self.redirect('/')
        else:
            # Nachsehen, ob eine Sprache ausgewählte wurde und wenn ja, welche Sprache
            sprache = aktuelle_sprache(username)
            navigations_bar = navigations_bar_funktion(sprache, mobile)

            url = users.create_logout_url(self.request.uri).replace(
                '&', '&amp;').replace('&amp;amp;', '&amp;')
            url_linktext = 'Logout'

            conn_region, regionname = login(username)
            zone_amazon = amazon_region(username)

            zonen_liste = zonen_liste_funktion(username, sprache, mobile)

            if sprache != "de":
                sprache = "en"

            input_error_message = error_messages.get(message, {}).get(sprache)

            # Wenn keine Fehlermeldung gefunden wird, ist das Ergebnis "None"
            if input_error_message == None:
                input_error_message = ""

            # Wenn die Nachricht grün formatiert werden soll...
            if message in ("105", "110"):
                # wird sie hier, in der Hilfsfunktion grün formatiert
                input_error_message = format_error_message_green(
                    input_error_message)
            # Ansonsten wird die Nachricht rot formatiert
            elif message in ("92", "106", "107", "108", "109"):
                input_error_message = format_error_message_red(
                    input_error_message)
            else:
                input_error_message = ""

            # Mit S3 verbinden
            conn_s3 = logins3(username)

            try:
                # Liste der Buckets
                liste_buckets = conn_s3.get_all_buckets()
            except:
                # Wenn es nicht klappt...
                if sprache == "de":
                    bucketstabelle = '<font color="red">Es ist zu einem Fehler gekommen</font>'
                else:
                    bucketstabelle = '<font color="red">An error occured</font>'
            else:
                # Wenn es geklappt hat...
                # Anzahl der Elemente in der Liste
                laenge_liste_buckets = len(liste_buckets)

                if laenge_liste_buckets == 0:
                    if sprache == "de":
                        bucketstabelle = 'Es sind keine Buckets in der Region vorhanden.'
                    else:
                        bucketstabelle = 'Still no buckets exist inside this region.'
                else:

                    if mobile == "true":
                        # Mobile version

                        bucketstabelle = ''
                        bucketstabelle += '<table border="0" cellspacing="0" cellpadding="5">'
                        for i in range(laenge_liste_buckets):
                            bucketstabelle += '<tr>'
                            bucketstabelle += '<td align="left">'
                            bucketstabelle += '<a href="/bucketentfernen?bucket='
                            bucketstabelle += str(liste_buckets[i].name)
                            bucketstabelle += "&amp;mobile="
                            bucketstabelle += str(mobile)
                            if sprache == "de":
                                bucketstabelle += '" title="Bucket l&ouml;schen"><img src="bilder/delete.png" width="16" height="16" border="0" alt="Bucket l&ouml;schen"></a>'
                            else:
                                bucketstabelle += '" title="erase bucket"><img src="bilder/delete.png" width="16" height="16" border="0" alt="erase bucket"></a>'
                            bucketstabelle += '</td>'
                            bucketstabelle += '<td colspan="4" align="left">' + str(
                                liste_buckets[i].name) + '</td>'
                            bucketstabelle += '</tr>'
                            bucketstabelle += '<tr>'
                            bucketstabelle += '<td>&nbsp;</td>'
                            if sprache == "de":
                                bucketstabelle += '<td align="right"><b>Reines S3:</b></td>'
                            else:
                                bucketstabelle += '<td align="right"><b>pure S3:</b></td>'
                            bucketstabelle += '<td align="left">'
                            bucketstabelle += '<a href="/bucket_inhalt_pure?bucket='
                            bucketstabelle += str(liste_buckets[i].name)
                            bucketstabelle += "&amp;mobile="
                            bucketstabelle += str(mobile)
                            if sprache == "de":
                                bucketstabelle += '" title="Bucket einsehen (reine S3-Darstellung)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                            else:
                                bucketstabelle += '" title="List content of this bucket (pure S3)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                            bucketstabelle += '</td>'
                            if sprache == "de":
                                bucketstabelle += '<td align="right"><b>Komfort S3:</b></td>'
                            else:
                                bucketstabelle += '<td align="right"><b>comfort S3:</b></td>'
                            bucketstabelle += '<td align="left">'
                            bucketstabelle += '<a href="/bucket_inhalt?bucket='
                            bucketstabelle += str(liste_buckets[i].name)
                            bucketstabelle += "&amp;mobile="
                            bucketstabelle += str(mobile)
                            if sprache == "de":
                                bucketstabelle += '" title="Bucket einsehen (Komfort-Darstellung)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                            else:
                                bucketstabelle += '" title="List content of this bucket (S3 with more comfort)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                            bucketstabelle += '</td>'
                            bucketstabelle += '</tr>'
                        bucketstabelle += '</table>'

                    else:
                        # Not the mobile version

                        bucketstabelle = ''
                        bucketstabelle += '<table border="0" cellspacing="0" cellpadding="5">'
                        bucketstabelle += '<tr>'
                        bucketstabelle += '<th>&nbsp;</th>'
                        bucketstabelle += '<th align="left">Buckets</th>'
                        if sprache == "de":
                            bucketstabelle += '<th>Reine S3-Darstellung</th>'
                            bucketstabelle += '<th>Komfort-Darstellung</th>'
                        else:
                            bucketstabelle += '<th>Pure S3</th>'
                            bucketstabelle += '<th>S3 with more comfort</th>'
                        bucketstabelle += '</tr>'
                        for i in range(laenge_liste_buckets):
                            bucketstabelle += '<tr>'
                            bucketstabelle += '<td>'
                            bucketstabelle += '<a href="/bucketentfernen?bucket='
                            bucketstabelle += str(liste_buckets[i].name)
                            bucketstabelle += "&amp;mobile="
                            bucketstabelle += str(mobile)
                            if sprache == "de":
                                bucketstabelle += '" title="Bucket l&ouml;schen"><img src="bilder/delete.png" width="16" height="16" border="0" alt="Bucket l&ouml;schen"></a>'
                            else:
                                bucketstabelle += '" title="erase bucket"><img src="bilder/delete.png" width="16" height="16" border="0" alt="erase bucket"></a>'
                            bucketstabelle += '</td>'
                            bucketstabelle += '<td>' + str(
                                liste_buckets[i].name) + '</td>'
                            bucketstabelle += '<td align="center">'
                            bucketstabelle += '<a href="/bucket_inhalt_pure?bucket='
                            bucketstabelle += str(liste_buckets[i].name)
                            if sprache == "de":
                                bucketstabelle += '" title="Bucket einsehen (reine S3-Darstellung)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                            else:
                                bucketstabelle += '" title="List content of this bucket (pure S3)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                            bucketstabelle += '</td>'
                            bucketstabelle += '<td align="center">'
                            bucketstabelle += '<a href="/bucket_inhalt?bucket='
                            bucketstabelle += str(liste_buckets[i].name)
                            if sprache == "de":
                                bucketstabelle += '" title="Bucket einsehen (Komfort-Darstellung)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                            else:
                                bucketstabelle += '" title="List content of this bucket (S3 with more comfort)"><img src="bilder/right.png" width="16" height="16" border="0" alt="Bucket"></a>'
                            bucketstabelle += '</td>'
                            bucketstabelle += '</tr>'
                        bucketstabelle += '</table>'

            path = '&amp;path=s3&amp;mobile=' + mobile

            template_values = {
                'navigations_bar': navigations_bar,
                'url': url,
                'url_linktext': url_linktext,
                'zone': regionname,
                'zone_amazon': zone_amazon,
                'zonen_liste': zonen_liste,
                'bucketstabelle': bucketstabelle,
                'input_error_message': input_error_message,
                'mobile': mobile,
                'path': path,
            }

            if mobile == "true":
                path = os.path.join(os.path.dirname(__file__),
                                    "../templates/mobile", sprache, "s3.html")
            else:
                path = os.path.join(os.path.dirname(__file__), "../templates",
                                    sprache, "s3.html")
            self.response.out.write(template.render(path, template_values))
Ejemplo n.º 11
0
    def get(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        #self.response.out.write('posted!')
        # Den Namen des zu löschen Keys holen
        keyname = self.request.get('key')
        # Namen des Buckets holen, aus dem der Key gelöscht werden soll
        bucketname = self.request.get('bucket')
        # War es die reine S3-Darstellung oder die Komfort-Darstellung, aus der die
        # Anfrage zu Löschen des Keys kam?
        typ = self.request.get('typ')
        # Das Verzeichnis aus dem Formular holen
        directory = self.request.get('dir')

        # Den Slash am Ende des Verzeichnisses entfernen
        directory = str(directory[:-1])

        # Den Usernamen erfahren
        username = users.get_current_user()

        # Mit S3 verbinden
        conn_s3 = logins3(username)

        bucket_instance = conn_s3.get_bucket(bucketname)
        # Liste der Keys im Bucket
        liste_keys = bucket_instance.get_all_keys()
        # Anzahl der Keys in der Liste
        laenge_liste_keys = len(liste_keys)

        for i in range(laenge_liste_keys):
            # Key-Name in einen String umwandeln
            vergleich = str(liste_keys[i].name)
            if vergleich == keyname:
                # Vergleichen
                try:
                    # Versuch den Key zu löschen
                    liste_keys[i].delete()
                except:
                    fehlermeldung = "112"
                    # Wenn es nicht klappt...
                    if typ == "pur":
                        if directory == "/":
                            self.redirect('/bucket_inhalt_pure?mobile=' +
                                          str(mobile) + '&bucket=' +
                                          bucketname + '&message=' +
                                          fehlermeldung)
                        else:
                            self.redirect('/bucket_inhalt_pure?mobile=' +
                                          str(mobile) + '&bucket=' +
                                          bucketname + '&message=' +
                                          fehlermeldung + '&dir=' + directory)
                    else:
                        if directory == "/":
                            self.redirect('/bucket_inhalt?mobile=' +
                                          str(mobile) + '&bucket=' +
                                          bucketname + '&message=' +
                                          fehlermeldung)
                        else:
                            self.redirect('/bucket_inhalt?mobile=' +
                                          str(mobile) + '&bucket=' +
                                          bucketname + '&message=' +
                                          fehlermeldung + '&dir=' + directory)
                else:
                    fehlermeldung = "111"
                    # Wenn es geklappt hat...
                    if typ == "pur":
                        if directory == "/":
                            self.redirect('/bucket_inhalt_pure?mobile=' +
                                          str(mobile) + '&bucket=' +
                                          bucketname + '&message=' +
                                          fehlermeldung)
                        else:
                            self.redirect('/bucket_inhalt_pure?mobile=' +
                                          str(mobile) + '&bucket=' +
                                          bucketname + '&message=' +
                                          fehlermeldung + '&dir=' + directory)
                    else:
                        if directory == "/":
                            self.redirect('/bucket_inhalt?mobile=' +
                                          str(mobile) + '&bucket=' +
                                          bucketname + '&message=' +
                                          fehlermeldung)
                        else:
                            self.redirect('/bucket_inhalt?mobile=' +
                                          str(mobile) + '&bucket=' +
                                          bucketname + '&message=' +
                                          fehlermeldung + '&dir=' + directory)
Ejemplo n.º 12
0
    def get(self):
        # self.response.out.write('posted!')

        # Get username
        username = users.get_current_user()
        if not username:
            self.redirect('/')
        # Get error messages if any exist
        message = self.request.get('message')

        # Datastore query that checks if any credentials for this user exist
        testen = db.GqlQuery(
            "SELECT * FROM OctopusCloudDatenbank WHERE user = :username_db",
            username_db=username)

        # How many entries of this user exist?
        anzahl = testen.count()

        # Get the result of your datastore query
        results = testen.fetch(100)

        if not results:
            self.redirect('/')
        else:
            # Datastore query that checks if credentials for Amazon S3 exist
            testen = db.GqlQuery(
                "SELECT * FROM OctopusCloudDatenbank WHERE user = :username_db AND zugangstyp = :zugangstyp_db",
                username_db=username,
                zugangstyp_db="Amazon")
            # Get the result of your datastore query
            results = testen.fetch(100)
            if results:
                # If credentials for Amazon S3 exist
                aktuellezone = "Amazon"
                eucalyptusname = "Amazon"
            else:
                # No credentials for Amazon S3 exist
                # Datastore query that checks if credentials for a Walrus (Eucalyptus) Private Cloud exist
                testen = db.GqlQuery(
                    "SELECT * FROM OctopusCloudDatenbank WHERE user = :username_db AND zugangstyp = :zugangstyp_db",
                    username_db=username,
                    zugangstyp_db="Eucalyptus")
                # Get the result of your datastore query
                results = testen.fetch(100)

                if results:
                    # If credentials for an Walrus (Eucalyptus) Private Cloud exist
                    aktuellezone = "Eucalyptus"
                    # Get the credentials for the Walrus (Eucalyptus) Private Cloud
                    anzahl = testen.count()
                    for test in results:
                        eucalyptusname = str(test.eucalyptusname)

                else:
                    # If no Walrus (Eucalyptus) credentials are given, we jump back to the root window
                    self.redirect('/')

            # Get the language of the user
            sprache = aktuelle_sprache(username)
            # Generate the navigations bar
            navigations_bar = navigations_bar_funktion(sprache)

            url = users.create_logout_url(self.request.uri).replace(
                '&', '&amp;').replace('&amp;amp;', '&amp;')
            url_linktext = 'Logout'

            # If the language is not set to german, it is set here to english
            if sprache != "de":
                sprache = "en"

            input_error_message = error_messages.get(message, {}).get(sprache)

            # If no error messages exist, the result here is "None".
            if input_error_message == None:
                input_error_message = ""

            # These error messages are formated in green...
            if message in ("111", "118", "120"):
                # This helper function formats in green
                input_error_message = format_error_message_green(
                    input_error_message)
            # These error messages are formated in red...
            elif message in ("112", "119", "121"):
                input_error_message = format_error_message_red(
                    input_error_message)
            else:
                input_error_message = ""

            # Get Access Kkey for storage service that is used to display the list of keys
            AWSAccessKeyId = aws_access_key_erhalten(username, eucalyptusname)
            # Get Secret Access Key for storage service that is used to display the list of keys
            AWSSecretAccessKeyId = aws_secret_access_key_erhalten(
                username, eucalyptusname)

            # Connect with storage service
            conn_s3, regionname = logins3(username, aktuellezone)

            # Get values from the config file
            # The name of the bucket that is used
            # The character "@" cannot be used. Therefore we use "at".
            bucketname = str(parser.get('bucket',
                                        'bucketname')) + str(username).replace(
                                            '@', 'at').replace('.', '-')

            try:
                # Connect with bucket
                bucket_instance = conn_s3.get_bucket(bucketname)
            except:
                # When it didn't work
                if sprache == "de":
                    bucket_keys_tabelle = '<font color="red">Es ist zu einem Fehler gekommen</font>'
                else:
                    bucket_keys_tabelle = '<font color="red">An error occured</font>'
                laenge_liste_keys = 0
            else:
                # When it worked...
                try:
                    # Get a list of all keys inside the bucket
                    liste_keys = bucket_instance.get_all_keys()
                except:
                    # When it didn't work
                    if sprache == "de":
                        bucket_keys_tabelle = '<font color="red">Es ist zu einem Fehler gekommen</font>'
                    else:
                        bucket_keys_tabelle = '<font color="red">An error occured</font>'
                    laenge_liste_keys = 0
                else:
                    # When it worked...
                    # Number of keys inside the list
                    laenge_liste_keys = len(liste_keys)

            # When using Walrus (Eucalyptus), we need to erase the stupid "None" entry.
#          if aktuellezone != "Amazon":
#            liste_keys2 = []
#            for i in range(laenge_liste_keys):
#              if str(liste_keys[i].name) != 'None':
#                liste_keys2.append(liste_keys[i])
#            laenge_liste_keys2 = len(liste_keys2)
#            laenge_liste_keys = laenge_liste_keys2
#            liste_keys = liste_keys2

# If we have more than one storage services, we need to compare the MD5 checksums
            if anzahl > 1:
                # If we have keys inside the bucket, we need to create a list that contains the MD5 checksums
                if laenge_liste_keys == 0:
                    # Create an empty List
                    Main_Liste = []
                    # Length of the List
                    Main_Liste_laenge = len(Main_Liste)
                    Second_list = get_second_list(username, aktuellezone,
                                                  eucalyptusname)
                    Second_list_laenge = len(Second_list)
                else:
                    # if laenge_liste_keys is not 0
                    # Create an empty List
                    Main_Liste = []
                    # Walk through the list of keys
                    for i in range(laenge_liste_keys):
                        # In S3 each MD5 checksum is enclosed by double quotes. In Walrus they are not
                        Main_Liste.append(
                            str(liste_keys[i].etag).replace('"', ''))
                    # Sort the List
                    Main_Liste.sort()
                    # Length of the List
                    Main_Liste_laenge = len(Main_Liste)
                    Second_list = get_second_list(username, aktuellezone,
                                                  eucalyptusname)
                    Second_list_laenge = len(Second_list)

#              self.response.out.write(Main_Liste)
#              self.response.out.write(Main_Liste_laenge)
#              self.response.out.write(Second_list)
#              self.response.out.write(Second_list_laenge)

            if laenge_liste_keys == 0:
                # No keys have been imported yet!
                if sprache == "de":
                    bucket_keys_tabelle = 'Sie haben noch keine Dateien importiert.'
                else:
                    bucket_keys_tabelle = 'No keys have been imported yet.'
            else:
                # There are keys in the bucket
                bucket_keys_tabelle = ''
                bucket_keys_tabelle = bucket_keys_tabelle + '<table border="3" cellspacing="0" cellpadding="5">'
                bucket_keys_tabelle = bucket_keys_tabelle + '<tr>'
                bucket_keys_tabelle = bucket_keys_tabelle + '<th>&nbsp;&nbsp;&nbsp;</th>'
                bucket_keys_tabelle = bucket_keys_tabelle + '<th>&nbsp;&nbsp;&nbsp;</th>'
                if sprache == "de":
                    bucket_keys_tabelle = bucket_keys_tabelle + '<th align="left">Keys</th>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '<th align="center">Dateigr&ouml;&szlig;e</th>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '<th align="center">Letzte &Auml;nderung</th>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '<th align="center">Zugriffsberechtigung</th>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '<th align="center">Pr&uuml;fsumme (MD5)</th>'
                else:
                    bucket_keys_tabelle = bucket_keys_tabelle + '<th align="left">Keys</th>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '<th align="center">Filesize</th>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '<th align="center">Last Modified</th>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '<th align="center">Access Control List</th>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '<th align="center">MD5</th>'
                bucket_keys_tabelle = bucket_keys_tabelle + '</tr>'

                for i in range(laenge_liste_keys):
                    bucket_keys_tabelle = bucket_keys_tabelle + '<tr>'
                    if liste_keys[i].name == None and aktuellezone != "Amazon":
                        bucket_keys_tabelle = bucket_keys_tabelle + '<td>&nbsp;</td>'
                    else:
                        bucket_keys_tabelle = bucket_keys_tabelle + '<td>'
                        bucket_keys_tabelle = bucket_keys_tabelle + '<a href="/bucketkeyentfernen?md5hash='
                        bucket_keys_tabelle = bucket_keys_tabelle + str(
                            liste_keys[i].etag).replace('"', '')
                        if sprache == "de":
                            bucket_keys_tabelle = bucket_keys_tabelle + '" title="Key l&ouml;schen"><img src="bilder/delete.png" width="16" height="16" border="0" alt="Key l&ouml;schen"></a>'
                        else:
                            bucket_keys_tabelle = bucket_keys_tabelle + '" title="erase key"><img src="bilder/delete.png" width="16" height="16" border="0" alt="erase key"></a>'
                        bucket_keys_tabelle = bucket_keys_tabelle + '</td>'

                    if liste_keys[i].name == None and aktuellezone != "Amazon":
                        bucket_keys_tabelle = bucket_keys_tabelle + '<td>&nbsp;</td>'
                    else:
                        bucket_keys_tabelle = bucket_keys_tabelle + '<td>'
                        if sprache == "de":
                            bucket_keys_tabelle = bucket_keys_tabelle + '<img src="bilder/document.png" width="16" height="16" border="0" alt="Datei">'
                        else:
                            bucket_keys_tabelle = bucket_keys_tabelle + '<img src="bilder/document.png" width="16" height="16" border="0" alt="File">'
                        bucket_keys_tabelle = bucket_keys_tabelle + '</td>'

                    bucket_keys_tabelle = bucket_keys_tabelle + '<td>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '<a href="'
                    bucket_keys_tabelle = bucket_keys_tabelle + liste_keys[
                        i].generate_url(600,
                                        method='GET',
                                        headers=None,
                                        query_auth=True,
                                        force_http=False).replace(
                                            '&', '&amp;').replace(
                                                '&amp;amp;', '&amp;')
                    bucket_keys_tabelle = bucket_keys_tabelle + '">'
                    bucket_keys_tabelle = bucket_keys_tabelle + str(
                        liste_keys[i].name)
                    bucket_keys_tabelle = bucket_keys_tabelle + '</a>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '</td>'

                    bucket_keys_tabelle = bucket_keys_tabelle + '<td align="right">'
                    if liste_keys[i].name == None and aktuellezone != "Amazon":
                        bucket_keys_tabelle = bucket_keys_tabelle + '&nbsp;'
                    else:
                        bucket_keys_tabelle = bucket_keys_tabelle + str(
                            liste_keys[i].size)
                    bucket_keys_tabelle = bucket_keys_tabelle + '</td>'

                    bucket_keys_tabelle = bucket_keys_tabelle + '<td>'
                    # Format ISO8601 timestring for better looking.
                    if liste_keys[i].name == None and aktuellezone != "Amazon":
                        bucket_keys_tabelle = bucket_keys_tabelle + '&nbsp;'
                    else:
                        datum_der_letzten_aenderung = parse(
                            liste_keys[i].last_modified)
                        bucket_keys_tabelle = bucket_keys_tabelle + str(
                            datum_der_letzten_aenderung.strftime(
                                "%Y-%m-%d  %H:%M:%S"))
                    bucket_keys_tabelle = bucket_keys_tabelle + '</td>'

                    bucket_keys_tabelle = bucket_keys_tabelle + '<td align="center">'
                    bucket_keys_tabelle = bucket_keys_tabelle + '<a href="/acl_einsehen?key='
                    bucket_keys_tabelle = bucket_keys_tabelle + str(
                        liste_keys[i].name)
                    bucket_keys_tabelle = bucket_keys_tabelle + '&amp;md5hash='
                    bucket_keys_tabelle = bucket_keys_tabelle + str(
                        liste_keys[i].etag).replace('"', '')
                    if sprache == "de":
                        bucket_keys_tabelle = bucket_keys_tabelle + '" title="ACL einsehen/&auml;ndern">ACL einsehen/&auml;ndern</a>'
                    else:
                        bucket_keys_tabelle = bucket_keys_tabelle + '" title="view/edit ACL">view/edit ACL</a>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '</td>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '<td align="center">'
                    bucket_keys_tabelle = bucket_keys_tabelle + '<tt>' + str(
                        liste_keys[i].etag).replace('"', '') + '</tt>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '</td>'
                    bucket_keys_tabelle = bucket_keys_tabelle + '</tr>'
                bucket_keys_tabelle = bucket_keys_tabelle + '</table>'

            #Documentation about howto upload keys into S3
            #http://docs.amazonwebservices.com/AmazonS3/latest/index.html?HTTPPOSTForms.html
            #http://doc.s3.amazonaws.com/proposals/post.html
            #http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1434
            #http://s3.amazonaws.com/doc/s3-example-code/post/post_sample.html

            # Create the policy dokument
            # expiration date is specified in ISO 8601 format.
            policy_document = ''
            policy_document = policy_document + '{'
            policy_document = policy_document + '"expiration": "2100-01-01T00:00:00Z",'
            policy_document = policy_document + '"conditions": ['
            policy_document = policy_document + '{"bucket": "' + bucketname + '"}, '
            policy_document = policy_document + '["starts-with", "$acl", ""],'
            policy_document = policy_document + '{"success_action_redirect": "http://cloudoctopus.appspot.com/S3"},'
            policy_document = policy_document + '["starts-with", "$key", ""],'
            policy_document = policy_document + '["starts-with", "$Content-Type", ""]'
            policy_document = policy_document + ']'
            policy_document = policy_document + '}'

            # Encode the policy document using Base64
            policy = base64.b64encode(policy_document)

            # Calculate the signature with the Secret Access Key and the policy
            signature = base64.b64encode(
                hmac.new(AWSSecretAccessKeyId, policy, sha).digest())

            # This is done all before.
            # !!! Silly programming !!!

            # Get data out of the DB
            alledaten = db.GqlQuery(
                "SELECT * FROM OctopusCloudDatenbank WHERE user = :username_db",
                username_db=username)
            # How many entries for this user exist?
            alledaten_clount = alledaten.count()
            # Get all data of user
            alledaten_ergebnisse = alledaten.fetch(100)
            i = 0
            # Walk through every line of the user in the DB
            for alledatendurchlauf in alledaten_ergebnisse:
                i = i + 1
                if i == 1:
                    regionname1 = str(alledatendurchlauf.regionname)
                    endpointurl1 = str(alledatendurchlauf.endpointurl)
                    accesskey1 = str(alledatendurchlauf.accesskey)
                    zugangstyp1 = str(alledatendurchlauf.zugangstyp)
                    eucalyptusname1 = str(alledatendurchlauf.eucalyptusname)
                    port1 = str(alledatendurchlauf.port)
                    ziel_adresse_upload1 = endpointurl1 + '/'

                    AWSSecretAccessKeyId1 = aws_secret_access_key_erhalten(
                        username, eucalyptusname1)
                    signature1 = base64.b64encode(
                        hmac.new(AWSSecretAccessKeyId1, policy, sha).digest())
                else:
                    regionname2 = str(alledatendurchlauf.regionname)
                    endpointurl2 = str(alledatendurchlauf.endpointurl)
                    accesskey2 = str(alledatendurchlauf.accesskey)
                    zugangstyp2 = str(alledatendurchlauf.zugangstyp)
                    eucalyptusname2 = str(alledatendurchlauf.eucalyptusname)
                    port2 = str(alledatendurchlauf.port)
                    ziel_adresse_upload2 = endpointurl2 + '/'

                    AWSSecretAccessKeyId2 = aws_secret_access_key_erhalten(
                        username, eucalyptusname2)
                    signature2 = base64.b64encode(
                        hmac.new(AWSSecretAccessKeyId2, policy, sha).digest())

#              self.response.out.write(regionname1 + '<BR>')
#              self.response.out.write(zugangstyp1 + '<BR>')
#              self.response.out.write(eucalyptusname1 + '<BR>')
#              self.response.out.write(accesskey1 + '<BR>')
#              self.response.out.write(AWSSecretAccessKeyId1 + '<BR>')
#              self.response.out.write(ziel_adresse_upload1+bucketname + '<BR>')
#
#              self.response.out.write(regionname2 + '<BR>')
#              self.response.out.write(zugangstyp2 + '<BR>')
#              self.response.out.write(eucalyptusname2 + '<BR>')
#              self.response.out.write(accesskey2 + '<BR>')
#              self.response.out.write(AWSSecretAccessKeyId2 + '<BR>')
#              self.response.out.write(ziel_adresse_upload2+bucketname + '<BR>')

            ajax_formular = ''
            ajax_formular = ajax_formular + '<script type="text/javascript" src="jquery.min.js"></script>\n'
            ajax_formular = ajax_formular + '<script type="text/javascript" src="upload.js"></script>\n'
            ajax_formular = ajax_formular + '<script type="text/javascript" src="jquery.blockUI.js"></script>\n'

            ajax_formular = ajax_formular + '<script type="text/javascript">'
            if anzahl == 1:

                #            if aktuellezone == "Eucalyptus":
                #              endpointurl = endpointurl_erhalten(username,eucalyptusname)
                #              port = port_erhalten(username,eucalyptusname)
                #              ziel_adresse =  str(endpointurl) + ':' + str(port) + '/services/Walrus/'
                if aktuellezone == "GoogleStorage":
                    ziel_adresse = 'commondatastorage.googleapis.com/'
                else:
                    # aktuellezone == "Amazon":
                    ziel_adresse = 's3.amazonaws.com/'

                ajax_formular = ajax_formular + 'var data = ['
                ajax_formular = ajax_formular + '{sUrl:"http://' + ziel_adresse + bucketname + '",'
                ajax_formular = ajax_formular + ' success_action_redirect:"http://cloudoctopus.appspot.com/S3",'
                ajax_formular = ajax_formular + ' AWSAccessKeyId:"' + AWSAccessKeyId + '",'
                ajax_formular = ajax_formular + ' policy:"' + policy + '",'
                ajax_formular = ajax_formular + ' signature:"' + signature + '"}'
                ajax_formular = ajax_formular + '];'
            else:
                ajax_formular = ajax_formular + 'var data = ['
                ajax_formular = ajax_formular + '{sUrl:"http://' + ziel_adresse_upload1 + bucketname + '",'
                ajax_formular = ajax_formular + ' success_action_redirect:"http://cloudoctopus.appspot.com/S3",'
                ajax_formular = ajax_formular + ' AWSAccessKeyId:"' + accesskey1 + '",'
                ajax_formular = ajax_formular + ' policy:"' + policy + '",'
                ajax_formular = ajax_formular + ' signature:"' + signature1 + '"}'
                ajax_formular = ajax_formular + ' ,'
                ajax_formular = ajax_formular + ' {sUrl:"http://' + ziel_adresse_upload2 + bucketname + '",'
                ajax_formular = ajax_formular + ' success_action_redirect:"http://cloudoctopus.appspot.com/S3",'
                ajax_formular = ajax_formular + ' AWSAccessKeyId:"' + accesskey2 + '",'
                ajax_formular = ajax_formular + ' policy:"' + policy + '",'
                ajax_formular = ajax_formular + ' signature:"' + signature2 + '"}'
                ajax_formular = ajax_formular + '];'
            ajax_formular = ajax_formular + '</script>\n'

            keys_upload_formular = '<p>&nbsp;</p>\n'
            keys_upload_formular = keys_upload_formular + '<form target="frame1" id="form1" action="" method="post" enctype="multipart/form-data">\n'
            keys_upload_formular = keys_upload_formular + '<table border="0" cellspacing="0" cellpadding="5">'
            keys_upload_formular = keys_upload_formular + '<tr>'
            keys_upload_formular = keys_upload_formular + '<td>'
            keys_upload_formular = keys_upload_formular + '<input type="hidden" name="key" value="${filename}">\n'
            keys_upload_formular = keys_upload_formular + '<select name="acl" size="1">\n'
            keys_upload_formular = keys_upload_formular + '<option selected="selected">public-read</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>private</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>public-read-write</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>authenticated-read</option>\n'
            keys_upload_formular = keys_upload_formular + '</select>\n'
            keys_upload_formular = keys_upload_formular + '<select name="Content-Type" size="1">\n'
            keys_upload_formular = keys_upload_formular + '<option selected="selected">application/octet-stream</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>application/pdf</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>application/zip</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>audio/mp4</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>audio/mpeg</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>audio/ogg</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>audio/vorbis</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>image/gif</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>image/jpeg</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>image/png</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>image/tiff</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>text/html</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>text/plain</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>video/mp4</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>video/mpeg</option>\n'
            keys_upload_formular = keys_upload_formular + '<option>video/ogg</option>\n'
            keys_upload_formular = keys_upload_formular + '</select>\n'
            keys_upload_formular = keys_upload_formular + '</td>\n'
            keys_upload_formular = keys_upload_formular + '</tr>\n'
            keys_upload_formular = keys_upload_formular + '<tr>\n'
            keys_upload_formular = keys_upload_formular + '<td>\n'

            keys_upload_formular = keys_upload_formular + '<input type="hidden" id="success_action_redirect" name="success_action_redirect" value="">\n'
            keys_upload_formular = keys_upload_formular + '<input type="hidden" id="AWSAccessKeyId" name="AWSAccessKeyId" value="">\n'
            keys_upload_formular = keys_upload_formular + '<input type="hidden" id="policy" name="policy" value="">\n'
            keys_upload_formular = keys_upload_formular + '<input type="hidden" id="signature" name="signature" value="">\n'

            #keys_upload_formular = keys_upload_formular + '<input type="hidden" id="submit" name="submit" value="submit">\n'

            keys_upload_formular = keys_upload_formular + '</td>\n'
            keys_upload_formular = keys_upload_formular + '</tr>\n'
            keys_upload_formular = keys_upload_formular + '<tr>\n'
            keys_upload_formular = keys_upload_formular + '<td>\n'
            keys_upload_formular = keys_upload_formular + '<input type="file" name="file" size="80">\n'
            keys_upload_formular = keys_upload_formular + '</td>\n'
            keys_upload_formular = keys_upload_formular + '</tr>\n'

            # Traditional Way to upload a Key into S3
            keys_upload_formular = keys_upload_formular + '<tr>'
            keys_upload_formular = keys_upload_formular + '<td>'
            if sprache == "de":
                keys_upload_formular = keys_upload_formular + '<input type="submit" style="display:none" id="button2" name="submit" value="Datei hochladen">\n'
            else:
                keys_upload_formular = keys_upload_formular + '<input type="submit" style="display:none" id="button2" name="submit" value="upload file">\n'
            keys_upload_formular = keys_upload_formular + '</td>'
            keys_upload_formular = keys_upload_formular + '</tr>'

            keys_upload_formular = keys_upload_formular + '</table>\n'
            keys_upload_formular = keys_upload_formular + '</form>'
            keys_upload_formular = keys_upload_formular + '\n'
            keys_upload_formular = keys_upload_formular + '<div id="statustext"></div>'
            keys_upload_formular = keys_upload_formular + '<div style="border:1px solid black;width:200px;height:20px"><div id="statusbar" style="background-color:black;width:1px;height:20px">&nbsp;</div></div>'

            if sprache == "de":
                keys_upload_formular = keys_upload_formular + '<button id="button1">Datei hochladen</button>'
            else:
                keys_upload_formular = keys_upload_formular + '<button id="button1">upload file</button>'

            iframe = '<iframe id="frame1" name="frame1" style="display:none"></iframe>'

            if laenge_liste_keys != 0:
                alle_keys_loeschen_button = '<p>&nbsp;</p>\n'
                alle_keys_loeschen_button = alle_keys_loeschen_button + '<form action="/alle_keys_loeschen" method="get">\n'
                alle_keys_loeschen_button = alle_keys_loeschen_button + '<input type="hidden" name="s3_ansicht" value="pur"> \n'
                alle_keys_loeschen_button = alle_keys_loeschen_button + '<input type="hidden" name="bucket_name" value="' + bucketname + '"> \n'
                if sprache == "de":
                    alle_keys_loeschen_button = alle_keys_loeschen_button + '<input type="submit" value="Alle Keys l&ouml;schen">\n'
                else:
                    alle_keys_loeschen_button = alle_keys_loeschen_button + '<input type="submit" value="Erase all keys">\n'
                alle_keys_loeschen_button = alle_keys_loeschen_button + '</form>\n'
            else:
                alle_keys_loeschen_button = ''

            if anzahl == 1:
                if sprache == "de":
                    redundanz_warnung = 'Sie nutzen aktuell nur einen Cloud-basierten Speicher-Dienst. '
                    redundanz_warnung = redundanz_warnung + 'Somit ist keine Redundanz m&ouml;glich!'
                    redundanz_warnung = redundanz_warnung + '<p>&nbsp;</p>'
                else:
                    redundanz_warnung = 'You use just a single cloud-based storage service. '
                    redundanz_warnung = redundanz_warnung + 'Therefore, the data is not stored in a redundant way!'
                    redundanz_warnung = redundanz_warnung + '<p>&nbsp;</p>'
            elif anzahl >= 1:
                if sprache == "de":
                    redundanz_warnung = 'Sie nutzen aktuell ' + str(
                        anzahl) + ' Cloud-basierte Speicher-Dienste. '
                    redundanz_warnung = redundanz_warnung + 'Somit ist Redundanz m&ouml;glich!'
                    redundanz_warnung = redundanz_warnung + '<p>&nbsp;</p>'
                else:
                    redundanz_warnung = 'You use ' + str(
                        anzahl) + ' cloud-based storage services. '
                    redundanz_warnung = redundanz_warnung + 'Therefore, the data can be stored in a redundant way!'
                    redundanz_warnung = redundanz_warnung + '<p>&nbsp;</p>'
            else:
                redundanz_warnung = ''

            if anzahl == 1:
                # If the number of storage services is 1, the data is always syncron
                synchron_warnung = ''
            else:
                # If there are more than one storage service, check if data is synchron
                # Check here for synchronicity
                if Main_Liste == Second_list:
                    # If both Lists are equal
                    if sprache == "de":
                        synchron_warnung = '<font color="green">Ihre Daten sind synchron</font>'
                        synchron_warnung = synchron_warnung + '<p>&nbsp;</p>'
                    else:
                        synchron_warnung = '<font color="green">Your data are synchron</font>'
                        synchron_warnung = synchron_warnung + '<p>&nbsp;</p>'
                else:
                    # If both Lists are not equal
                    if sprache == "de":
                        synchron_warnung = '<font color="red">Ihre Daten sind nicht synchron!</font>'
                        synchron_warnung = synchron_warnung + '<p>&nbsp;</p>'
                    else:
                        synchron_warnung = '<font color="red">The synchronicity of your data is broken!</font>'
                        synchron_warnung = synchron_warnung + '<p>&nbsp;</p>'

            template_values = {
                'navigations_bar': navigations_bar,
                'url': url,
                'url_linktext': url_linktext,
                'bucket_keys_tabelle': bucket_keys_tabelle,
                'input_error_message': input_error_message,
                'keys_upload_formular': keys_upload_formular,
                'alle_keys_loeschen_button': alle_keys_loeschen_button,
                'redundanz_warnung': redundanz_warnung,
                'ajax_formular': ajax_formular,
                'iframe': iframe,
                'synchron_warnung': synchron_warnung
            }

            path = os.path.join(os.path.dirname(__file__), "../templates",
                                sprache, "s3.html")
            self.response.out.write(template.render(path, template_values))
Ejemplo n.º 13
0
    def post(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        # self.response.out.write('posted!')
        # Die Eingabe aus dem Formular holen
        neuerbucketname = self.request.get('bucketname')

        # Den Usernamen erfahren
        username = users.get_current_user()

        if neuerbucketname == "":
          # Testen ob ein Name für den neuen key angegeben wurde
          # Wenn kein Name angegeben wurde, kann kein Key angelegt werden
          #fehlermeldung = "Sie haben keine Namen angegeben"
          fehlermeldung = "92"
          self.redirect('/s3?mobile='+str(mobile)+'&message='+fehlermeldung)
        elif re.search(r'[^\-.a-zA-Z0-9]', neuerbucketname) != None:
          # Testen ob der Name für den neuen key nicht erlaubte Zeichen enthält
          fehlermeldung = "106"
          self.redirect('/s3?mobile='+str(mobile)+'&message='+fehlermeldung)
        else:
          # Mit S3 verbinden
          conn_s3 = logins3(username)
          try:
            # Liste der Buckets
            liste_buckets = conn_s3.get_all_buckets()
          except:
            # Wenn es nicht klappt...
            fehlermeldung = "107"
            self.redirect('/s3?mobile='+str(mobile)+'&message='+fehlermeldung)
          else:
            # Wenn es geklappt hat...
            # Variable erzeugen zum Erfassen, ob der neue Bucket schon existiert
            laenge_liste_buckets = len(liste_buckets)

            # Variable erzeugen zum Erfassen, ob der neue Bucket schon existiert
            schon_vorhanden = 0
            for i in range(laenge_liste_buckets):
              # Bucket-Namen in einen String umwandeln
              vergleich = str(liste_buckets[i].name)
              # Vergleichen
              if vergleich == neuerbucketname:
                # Bucket-Name existiert schon!
                schon_vorhanden = 1

            if schon_vorhanden == 0:
              # Wenn man noch keinen Bucket mit dem eingegebenen Namen besitzt...
              try:
                # Versuch den Bucket anzulegen
                conn_s3.create_bucket(neuerbucketname)
              except:
                fehlermeldung = "107"
                # Wenn es nicht klappt...
                self.redirect('/s3?mobile='+str(mobile)+'&message='+fehlermeldung)
              else:
                fehlermeldung = "105"
                # Wenn es geklappt hat...
                self.redirect('/s3?mobile='+str(mobile)+'&message='+fehlermeldung)
            else:
              # Wenn man schon einen Bucket mit dem eingegeben Namen hat...
              fehlermeldung = "108"
              self.redirect('/s3?mobile='+str(mobile)+'&message='+fehlermeldung)
Ejemplo n.º 14
0
    def get(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        # self.response.out.write('posted!')
        # Den Usernamen erfahren
        username = users.get_current_user()
        if not username:
          self.redirect('/')
        # Eventuell vorhande Fehlermeldung holen
        message = self.request.get('message')
        # Namen des Buckets holen, dessen Inhalt angezeigt wird
        bucketname = self.request.get('bucket')

        # Nachsehen, ob eine Region/Zone ausgewählte wurde
        aktivezone = db.GqlQuery("SELECT * FROM KoalaCloudDatenbankAktiveZone WHERE user = :username_db", username_db=username)
        results = aktivezone.fetch(100)

        if not results:
          self.redirect('/')
        else:
          # Nachsehen, ob eine Sprache ausgewählte wurde und wenn ja, welche Sprache
          sprache = aktuelle_sprache(username)
          navigations_bar = navigations_bar_funktion(sprache,mobile)

          results = aktivezone.fetch(100)

          url = users.create_logout_url(self.request.uri).replace('&', '&amp;').replace('&amp;amp;', '&amp;')
          #url = users.create_logout_url(self.request.uri)
          url_linktext = 'Logout'

          conn_region, regionname = login(username)
          zone_amazon = amazon_region(username)
          zugangstyp = zugangstyp_erhalten(username) 

          zonen_liste = zonen_liste_funktion(username,sprache,mobile)

          if sprache != "de":
            sprache = "en"

          input_error_message = error_messages.get(message, {}).get(sprache)

          # Wenn keine Fehlermeldung gefunden wird, ist das Ergebnis "None"
          if input_error_message == None:
            input_error_message = ""

          # Wenn die Nachricht grün formatiert werden soll...
          if message in ("111", "118", "120"):
            # wird sie hier, in der Hilfsfunktion grün formatiert
            input_error_message = format_error_message_green(input_error_message)
          # Ansonsten wird die Nachricht rot formatiert
          elif message in ("112", "119", "121"):
            input_error_message = format_error_message_red(input_error_message)
          else:
            input_error_message = ""


          AWSAccessKeyId = aws_access_key_erhalten(username,regionname)
          AWSSecretAccessKeyId = aws_secret_access_key_erhalten(username,regionname)


          # Mit S3 verbinden
          conn_s3 = logins3(username)
          
          try:
            # Liste der Buckets
            bucket_instance = conn_s3.get_bucket(bucketname)
          except:
            # Wenn es nicht klappt...
            if sprache == "de":
              bucket_keys_tabelle = '<font color="red">Es ist zu einem Fehler gekommen</font>'
            else:
              bucket_keys_tabelle = '<font color="red">An error occured</font>'
            laenge_liste_keys = 0
            # Wenn es geklappt hat...
          else:
            try:
              # Liste der Keys
              liste_keys = bucket_instance.get_all_keys()
            except:
              # Wenn es nicht klappt...
              if sprache == "de":
                bucket_keys_tabelle = '<font color="red">Es ist zu einem Fehler gekommen</font>'
              else:
                bucket_keys_tabelle = '<font color="red">An error occured</font>'
              laenge_liste_keys = 0
            else:
              # Wenn es geklappt hat...
              # Anzahl der Keys in der Liste
              laenge_liste_keys = len(liste_keys)
  
            # Wenn wir in einer Eucalyputs-Infrastruktur sind, dann muss dieser
            # dämliche None-Eintrag weg
            if regionname != "Amazon":
              liste_keys2 = []
              for i in range(laenge_liste_keys):
                if str(liste_keys[i].name) != 'None':
                  liste_keys2.append(liste_keys[i])
              laenge_liste_keys2 = len(liste_keys2)
              laenge_liste_keys = laenge_liste_keys2
              liste_keys = liste_keys2
  
  
            if laenge_liste_keys == 0:
              if sprache == "de":
                bucket_keys_tabelle = 'Der Bucket <B>'+ bucketname+' </B>ist leer.'
              else:
                bucket_keys_tabelle = 'The bucket <B>'+ bucketname+' </B>is empty.'
            else:
              
              if mobile == "true":
                # mobile version...
                
                bucket_keys_tabelle = ''
                bucket_keys_tabelle += '<table border="0" cellspacing="0" cellpadding="5" width="300">'
    
                counter = 0
                for i in range(laenge_liste_keys):
                  
                    if counter > 0:
                        bucket_keys_tabelle += '<tr><td colspan="3">&nbsp;</td></tr>'
                    counter += 1
                    
                    bucket_keys_tabelle += '<tr>'
                    if liste_keys[i].name == None and regionname != "Amazon":
                      bucket_keys_tabelle += '<td>&nbsp;</td>'
                    else:
                      bucket_keys_tabelle += '<td>'
                      bucket_keys_tabelle += '<a href="/bucketkeyentfernen?bucket='
                      bucket_keys_tabelle += str(bucketname)
                      bucket_keys_tabelle += '&amp;typ=pur'
                      bucket_keys_tabelle += '&amp;key='
                      bucket_keys_tabelle += str(liste_keys[i].name)
                      bucket_keys_tabelle += "&amp;mobile="
                      bucket_keys_tabelle += str(mobile)
                      if sprache == "de":
                        bucket_keys_tabelle += '" title="Key l&ouml;schen"><img src="bilder/delete.png" width="16" height="16" border="0" alt="Key l&ouml;schen"></a>'
                      else:
                        bucket_keys_tabelle += '" title="erase key"><img src="bilder/delete.png" width="16" height="16" border="0" alt="erase key"></a>'
                      bucket_keys_tabelle += '</td>'
     
                    bucket_keys_tabelle += '<td colspan="2" align="left">'
                    bucket_keys_tabelle += '<a href="'
                    if regionname == "Amazon":
                      bucket_keys_tabelle += liste_keys[i].generate_url(600, method='GET', headers=None, query_auth=True, force_http=True).replace('&', '&amp;').replace('&amp;amp;', '&amp;')
                    else:
                      port = port_erhalten(username,regionname) 
                      bucket_keys_tabelle += liste_keys[i].generate_url(600, method='GET', headers=None, query_auth=True, force_http=True).replace('&', '&amp;').replace('&amp;amp;', '&amp;').replace('/services/Walrus/', ':'+str(port)+'/services/Walrus/')
                    bucket_keys_tabelle += '">'
                    bucket_keys_tabelle += str(liste_keys[i].name)
                    bucket_keys_tabelle += '</a>'
                    bucket_keys_tabelle += '</td>'
                    
                    bucket_keys_tabelle += '</tr>'
                    bucket_keys_tabelle += '<tr>'    
                    if sprache == "de":
                      bucket_keys_tabelle += '<td align="right" colspan="2"><b>Gr&ouml;&szlig;e:</b></td>'
                    else:
                      bucket_keys_tabelle += '<td align="right" colspan="2"><b>Size:</b></td>'
                    bucket_keys_tabelle += '<td align="left">'
                    if liste_keys[i].name == None and regionname != "Amazon":
                      bucket_keys_tabelle += '&nbsp;'
                    else:
                      bucket_keys_tabelle += str(liste_keys[i].size)
                    bucket_keys_tabelle += '</td>'
                    
                    bucket_keys_tabelle += '</tr>'
                    bucket_keys_tabelle += '<tr>'    
                    
                    if sprache == "de":
                      bucket_keys_tabelle += '<td align="right" colspan="2"><b>Datum:</b></td>'
                    else:
                      bucket_keys_tabelle += '<td align="right" colspan="2"><b>Date:</b></td>'
                    bucket_keys_tabelle += '<td align="left">'
                    # Den ISO8601 Zeitstring umwandeln, damit es besser aussieht.
                    if liste_keys[i].name == None and regionname != "Amazon":
                      bucket_keys_tabelle += '&nbsp;'
                    else:
                      datum_der_letzten_aenderung = parse(liste_keys[i].last_modified)
                      bucket_keys_tabelle += str(datum_der_letzten_aenderung.strftime("%Y-%m-%d  %H:%M:%S"))
                    bucket_keys_tabelle += '</td>'
                    
                    bucket_keys_tabelle += '</tr>'
                    bucket_keys_tabelle += '<tr>'    
                    
                    bucket_keys_tabelle += '<td align="right" colspan="2"><b>ACL:</b></td>'
                    bucket_keys_tabelle += '<td align="left">'
                    bucket_keys_tabelle += '<a href="/acl_einsehen?bucket='
                    bucket_keys_tabelle += str(bucketname)
                    bucket_keys_tabelle += '&amp;typ=pur'
                    bucket_keys_tabelle += '&amp;key='
                    bucket_keys_tabelle += str(liste_keys[i].name)
                    bucket_keys_tabelle += "&amp;mobile="
                    bucket_keys_tabelle += str(mobile)
                    if sprache == "de":
                      bucket_keys_tabelle += '" title="einsehen/&auml;ndern">einsehen/&auml;ndern</a>'
                    else:
                      bucket_keys_tabelle += '" title="view/edit">view/edit</a>'
                    bucket_keys_tabelle += '</td>'
                    
                    bucket_keys_tabelle += '</tr>'
                    bucket_keys_tabelle += '<tr>'    

                    # In S3 and Google Storage, each MD5 checksum is enclosed by double quotes.
                    # Eliminate them with .replace('"','')
                    bucket_keys_tabelle += '<td align="right" colspan="2"><b>MD5:</b></td>'
                    bucket_keys_tabelle += '<td align="left">'+str(liste_keys[i].etag.replace('"',''))+'</td>'
                    bucket_keys_tabelle += '</tr>'
                bucket_keys_tabelle += '</table>'              
              
              else:
                # not the mobile version
                              
                bucket_keys_tabelle = ''
                bucket_keys_tabelle += '<table border="0" cellspacing="0" cellpadding="5">'
    
                counter = 0
                for i in range(laenge_liste_keys):
                  
                    if counter > 0:
                        bucket_keys_tabelle += '<tr><td colspan="4">&nbsp;</td></tr>'
                    counter += 1
                    
                    bucket_keys_tabelle += '<tr>'
                    if liste_keys[i].name == None and regionname != "Amazon":
                      bucket_keys_tabelle += '<td>&nbsp;</td>'
                    else:
                      bucket_keys_tabelle += '<td align="left" bgcolor="#D4D4D4">'
                      bucket_keys_tabelle += '<a href="/bucketkeyentfernen?bucket='
                      bucket_keys_tabelle += str(bucketname)
                      bucket_keys_tabelle += '&amp;typ=pur'
                      bucket_keys_tabelle += '&amp;key='
                      bucket_keys_tabelle += str(liste_keys[i].name)
                      bucket_keys_tabelle += "&amp;mobile="
                      bucket_keys_tabelle += str(mobile)
                      if sprache == "de":
                        bucket_keys_tabelle += '" title="Key l&ouml;schen"><img src="bilder/delete.png" width="16" height="16" border="0" alt="Key l&ouml;schen"></a>'
                      else:
                        bucket_keys_tabelle += '" title="erase key"><img src="bilder/delete.png" width="16" height="16" border="0" alt="erase key"></a>'
                      bucket_keys_tabelle += '</td>'
     
                    bucket_keys_tabelle += '<td colspan="3" align="left" bgcolor="#D4D4D4">&nbsp;</td>'
     
                    bucket_keys_tabelle += '</tr>'
                    bucket_keys_tabelle += '<tr>'   
     
                    bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>ID:</b></td>'
                    bucket_keys_tabelle += '<td colspan="3" align="left">'
                    bucket_keys_tabelle += '<a href="'
                    if regionname == "Amazon":
                      bucket_keys_tabelle += liste_keys[i].generate_url(600, method='GET', headers=None, query_auth=True, force_http=True).replace('&', '&amp;').replace('&amp;amp;', '&amp;')
                    else:
                      port = port_erhalten(username,regionname) 
                      bucket_keys_tabelle += liste_keys[i].generate_url(600, method='GET', headers=None, query_auth=True, force_http=True).replace('&', '&amp;').replace('&amp;amp;', '&amp;').replace('/services/Walrus/', ':'+str(port)+'/services/Walrus/')
                    bucket_keys_tabelle += '">'
                    bucket_keys_tabelle += str(liste_keys[i].name)
                    bucket_keys_tabelle += '</a>'
                    bucket_keys_tabelle += '</td>'
                    
                    bucket_keys_tabelle += '</tr>'
                    bucket_keys_tabelle += '<tr>'    
                    if sprache == "de":
                      bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>Gr&ouml;&szlig;e:</b></td>'
                    else:
                      bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>Size:</b></td>'
                    bucket_keys_tabelle += '<td align="left">'
                    if liste_keys[i].name == None and regionname != "Amazon":
                      bucket_keys_tabelle += '&nbsp;'
                    else:
                      bucket_keys_tabelle += str(liste_keys[i].size)
                    bucket_keys_tabelle += '</td>'

                    if sprache == "de":
                      bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>Datum:</b></td>'
                    else:
                      bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>Date:</b></td>'
                    bucket_keys_tabelle += '<td align="left">'
                    # Den ISO8601 Zeitstring umwandeln, damit es besser aussieht.
                    if liste_keys[i].name == None and regionname != "Amazon":
                      bucket_keys_tabelle += '&nbsp;'
                    else:
                      datum_der_letzten_aenderung = parse(liste_keys[i].last_modified)
                      bucket_keys_tabelle += str(datum_der_letzten_aenderung.strftime("%Y-%m-%d  %H:%M:%S"))
                    bucket_keys_tabelle += '</td>'
                    
                    bucket_keys_tabelle += '</tr>'
                    bucket_keys_tabelle += '<tr>'    
                    
                    bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>ACL:</b></td>'
                    bucket_keys_tabelle += '<td align="left">'
                    bucket_keys_tabelle += '<a href="/acl_einsehen?bucket='
                    bucket_keys_tabelle += str(bucketname)
                    bucket_keys_tabelle += '&amp;typ=pur'
                    bucket_keys_tabelle += '&amp;key='
                    bucket_keys_tabelle += str(liste_keys[i].name)
                    bucket_keys_tabelle += "&amp;mobile="
                    bucket_keys_tabelle += str(mobile)
                    if sprache == "de":
                      bucket_keys_tabelle += '" title="einsehen/&auml;ndern">einsehen/&auml;ndern</a>'
                    else:
                      bucket_keys_tabelle += '" title="view/edit">view/edit</a>'
                    bucket_keys_tabelle += '</td>'
                    
                    # In S3 and Google Storage, each MD5 checksum is enclosed by double quotes.
                    # Eliminate them with .replace('"','')
                    bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>MD5:</b></td>'
                    bucket_keys_tabelle += '<td align="left">'+str(liste_keys[i].etag.replace('"',''))+'</td>'
                    bucket_keys_tabelle += '</tr>'
                bucket_keys_tabelle += '</table>'    
                

          # Wenn man sich NICHT unter Amazon befindet, funktioniert der Download von Keys nicht.
#          if regionname != "Amazon":
#            if sprache == "de":
#              eucalyptus_warnung = '<B>Achtung!</B> Unter Eucalyptus 1.6 und 1.6.1 funktioniert der Download von Keys nicht. Dabei handelt es sich um einen Fehler von Eucalyptus. Es kommt zu dieser Fehlermeldung: <B>Failure: 500 Internal Server Error</B>'
#            else:
#              eucalyptus_warnung = '<B>Attention!</B> With Eucalyptus 1.6 and 1.6.1 the download of Keys is broken. This is a bug of Eucalyptus. The result is this error message: <B>Failure: 500 Internal Server Error</B>'
#          else: 
#            eucalyptus_warnung = ''


          #Dokumentation zum Upload von Keys
          #http://docs.amazonwebservices.com/AmazonS3/latest/index.html?HTTPPOSTForms.html
          #http://doc.s3.amazonaws.com/proposals/post.html
          #http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1434
          #http://s3.amazonaws.com/doc/s3-example-code/post/post_sample.html

          # Hier wird das Policy-Dokument erzeugt
          policy_document = ''
          policy_document = policy_document + '{'
          policy_document = policy_document + '"expiration": "2100-01-01T00:00:00Z",'
          policy_document = policy_document + '"conditions": ['
          policy_document = policy_document + '{"bucket": "'+bucketname+'"}, '
          policy_document = policy_document + '["starts-with", "$acl", ""],'
          if mobile == "true":
            policy_document = policy_document + '{"success_action_redirect": "http://koalacloud.appspot.com/bucket_inhalt_pure?mobile=true"},'
          else:
            policy_document = policy_document + '{"success_action_redirect": "http://koalacloud.appspot.com/bucket_inhalt_pure?mobile=false"},'
          policy_document = policy_document + '["starts-with", "$key", ""],'
          policy_document = policy_document + '["starts-with", "$Content-Type", ""]'
          policy_document = policy_document + ']'
          policy_document = policy_document + '}'

          policy = base64.b64encode(policy_document)

          signature = base64.b64encode(hmac.new(AWSSecretAccessKeyId, policy, sha).digest())

           
           
          keys_upload_formular = ''
          if zugangstyp == "Eucalyptus":
            endpointurl = endpointurl_erhalten(username,regionname)
            port = port_erhalten(username,regionname) 
            keys_upload_formular += '<form action="http://'+str(endpointurl)+':'+str(port)+'/services/Walrus/'+bucketname+'" method="post" enctype="multipart/form-data">\n'
          elif zugangstyp == "GoogleStorage":
            keys_upload_formular += '<form action="http://commondatastorage.googleapis.com/'+bucketname+'" method="post" enctype="multipart/form-data">\n'
          elif zugangstyp == "HostEuropeCloudStorage":
            keys_upload_formular += '<form action="http://'+bucketname+'.cs.hosteurope.de'
            keys_upload_formular += '" method="post" enctype="multipart/form-data">\n'
          elif zugangstyp == "DunkelCloudStorage":
            keys_upload_formular += '<form action="http://'+bucketname+'.dcs.dunkel.de'
            keys_upload_formular += '" method="post" enctype="multipart/form-data">\n'
          else:
            keys_upload_formular += '<form action="http://s3.amazonaws.com/'+bucketname+'" method="post" enctype="multipart/form-data">\n'
          
          if mobile == "true":
            # mobile version...
            keys_upload_formular += '<table border="0" cellspacing="0" cellpadding="5">\n'
            keys_upload_formular += '<tr>\n'
            keys_upload_formular += '<td>\n'
            keys_upload_formular += '<input type="hidden" name="key" value="${filename}">\n'
            keys_upload_formular += '<select name="acl" size="1">\n'
            keys_upload_formular += '<option selected="selected">public-read</option>\n'
            keys_upload_formular += '<option>private</option>\n'
            keys_upload_formular += '<option>public-read-write</option>\n'
            keys_upload_formular += '<option>authenticated-read</option>\n'
            keys_upload_formular += '</select>\n'
            keys_upload_formular += '</td>'
            keys_upload_formular += '</tr>'
            keys_upload_formular += '<tr>'
            keys_upload_formular += '<td>'
            keys_upload_formular += '<select name="Content-Type" size="1">\n'
            keys_upload_formular += '<option selected="selected">application/octet-stream</option>\n'
            keys_upload_formular += '<option>application/pdf</option>\n'
            keys_upload_formular += '<option>application/zip</option>\n'
            keys_upload_formular += '<option>audio/mp4</option>\n'
            keys_upload_formular += '<option>audio/mpeg</option>\n'
            keys_upload_formular += '<option>audio/ogg</option>\n'
            keys_upload_formular += '<option>audio/vorbis</option>\n'
            keys_upload_formular += '<option>image/gif</option>\n'
            keys_upload_formular += '<option>image/jpeg</option>\n'
            keys_upload_formular += '<option>image/png</option>\n'
            keys_upload_formular += '<option>image/tiff</option>\n'
            keys_upload_formular += '<option>text/html</option>\n'
            keys_upload_formular += '<option>text/plain</option>\n'
            keys_upload_formular += '<option>video/mp4</option>\n'
            keys_upload_formular += '<option>video/mpeg</option>\n'
            keys_upload_formular += '<option>video/ogg</option>\n'
            keys_upload_formular += '</select>\n'
            keys_upload_formular += '</td>'
            keys_upload_formular += '</tr>'
            keys_upload_formular += '<tr>'
            keys_upload_formular += '<td>\n'
            keys_upload_formular += '<input type="hidden" name="success_action_redirect" value="http://koalacloud.appspot.com/bucket_inhalt_pure?mobile=true">\n'        
            keys_upload_formular += '<input type="hidden" name="AWSAccessKeyId" value="'+AWSAccessKeyId+'">\n'
            keys_upload_formular += '<input type="hidden" name="policy" value="'+policy+'">\n'
            keys_upload_formular += '<input type="hidden" name="signature" value="'+signature+'">\n'
            keys_upload_formular += '<input type="file" name="file" size="20">\n'
            keys_upload_formular += '</td>'
            keys_upload_formular += '</tr>'
            keys_upload_formular += '<tr>'
            keys_upload_formular += '<td>'
            if sprache == "de":
              keys_upload_formular += '<input type="submit" value="Objekt in den Bucket hochladen">\n'
            else:
              keys_upload_formular += '<input type="submit" value="upload objekt into bucket">\n'
            keys_upload_formular += '</td>'
            keys_upload_formular += '</tr>'
            keys_upload_formular += '</table>'
            keys_upload_formular += '</form>'
          else: 
            # Not the mobile version
            keys_upload_formular += '<table border="0" cellspacing="0" cellpadding="5">'
            keys_upload_formular += '<tr>'
            keys_upload_formular += '<td>'
            keys_upload_formular += '<input type="hidden" name="key" value="${filename}">\n'
            keys_upload_formular += '<select name="acl" size="1">\n'
            keys_upload_formular += '<option selected="selected">public-read</option>\n'
            keys_upload_formular += '<option>private</option>\n'
            keys_upload_formular += '<option>public-read-write</option>\n'
            keys_upload_formular += '<option>authenticated-read</option>\n'
            keys_upload_formular += '</select>\n'
            keys_upload_formular += '<select name="Content-Type" size="1">\n'
            keys_upload_formular += '<option selected="selected">application/octet-stream</option>\n'
            keys_upload_formular += '<option>application/pdf</option>\n'
            keys_upload_formular += '<option>application/zip</option>\n'
            keys_upload_formular += '<option>audio/mp4</option>\n'
            keys_upload_formular += '<option>audio/mpeg</option>\n'
            keys_upload_formular += '<option>audio/ogg</option>\n'
            keys_upload_formular += '<option>audio/vorbis</option>\n'
            keys_upload_formular += '<option>image/gif</option>\n'
            keys_upload_formular += '<option>image/jpeg</option>\n'
            keys_upload_formular += '<option>image/png</option>\n'
            keys_upload_formular += '<option>image/tiff</option>\n'
            keys_upload_formular += '<option>text/html</option>\n'
            keys_upload_formular += '<option>text/plain</option>\n'
            keys_upload_formular += '<option>video/mp4</option>\n'
            keys_upload_formular += '<option>video/mpeg</option>\n'
            keys_upload_formular += '<option>video/ogg</option>\n'
            keys_upload_formular += '</select>\n'
            keys_upload_formular += '</td>'
            keys_upload_formular += '</tr>'
            keys_upload_formular += '<tr>'
            keys_upload_formular += '<td>\n'
            keys_upload_formular += '<input type="hidden" name="success_action_redirect" value="http://koalacloud.appspot.com/bucket_inhalt_pure?mobile=false">\n'        
            keys_upload_formular += '<input type="hidden" name="AWSAccessKeyId" value="'+AWSAccessKeyId+'">\n'
            keys_upload_formular += '<input type="hidden" name="policy" value="'+policy+'">\n'
            keys_upload_formular += '<input type="hidden" name="signature" value="'+signature+'">\n'
            keys_upload_formular += '<input type="file" name="file" size="60">\n'
            keys_upload_formular += '</td>'
            keys_upload_formular += '</tr>'
            keys_upload_formular += '<tr>'
            keys_upload_formular += '<td>'
            if sprache == "de":
              keys_upload_formular += '<input type="submit" value="Objekt in den Bucket hochladen">\n'
            else:
              keys_upload_formular += '<input type="submit" value="upload objekt into bucket">\n'
            keys_upload_formular += '</td>'
            keys_upload_formular += '</tr>'
            keys_upload_formular += '</table>'
            keys_upload_formular += '</form>'
         
          # Unter Eucalyptus funktioniert das Hochladen von Keys nicht
          #else:
          #  if sprache == "de":
          #    keys_upload_formular = '<p>&nbsp;</p>\n Das Hochladen von Keys funktioniert unter Eucalyptus noch nicht'
          #  else:
          #    keys_upload_formular = '<p>&nbsp;</p>\n The key upload is still not working with Eucaplyptus'


          if laenge_liste_keys != 0:
            alle_keys_loeschen_button = '<p>&nbsp;</p>\n'
            alle_keys_loeschen_button += '<form action="/alle_keys_loeschen" method="get">\n'
            alle_keys_loeschen_button += '<input type="hidden" name="mobile" value="'+mobile+'">'
            alle_keys_loeschen_button += '<input type="hidden" name="s3_ansicht" value="pur"> \n'
            alle_keys_loeschen_button += '<input type="hidden" name="bucket_name" value="'+bucketname+'"> \n'
            if sprache == "de":
              alle_keys_loeschen_button += '<input type="submit" value="Alle Objekte l&ouml;schen">\n'
            else:
              alle_keys_loeschen_button += '<input type="submit" value="Erase all objects">\n'
            alle_keys_loeschen_button += '</form>\n'
          else:
            alle_keys_loeschen_button = ''

          path = '&amp;path=bucket_inhalt_pure&amp;bucket='+bucketname+'&amp;mobile='+mobile
          
          template_values = {
          'navigations_bar': navigations_bar,
          'url': url,
          'url_linktext': url_linktext,
          'zone': regionname,
          'zone_amazon': zone_amazon,
          'zonen_liste': zonen_liste,
          'bucket_keys_tabelle': bucket_keys_tabelle,
          'input_error_message': input_error_message,
          'bucketname': bucketname,
          'keys_upload_formular': keys_upload_formular,
          #'eucalyptus_warnung': eucalyptus_warnung,
          'alle_keys_loeschen_button': alle_keys_loeschen_button,
          'mobile': mobile,
          'path': path,
          }

          if mobile == "true":
              path = os.path.join(os.path.dirname(__file__), "../templates/mobile", sprache, "s3_keys_pur.html")
          else:
              path = os.path.join(os.path.dirname(__file__), "../templates", sprache, "s3_keys_pur.html")
          self.response.out.write(template.render(path,template_values))
Ejemplo n.º 15
0
    def get(self):
        # Namen des Keys holen, dessen ACL angezeigt wird
        keyname = self.request.get('key')
        # Get the MD5 hash of the key that need to be erased
        md5hash = self.request.get('md5hash')
        
        # Get the username
        username = users.get_current_user()
        if not username:
          self.redirect('/')
          
        # Nachsehen, ob Credentials von diesem Benutzer eingeneben wurden
        testen = db.GqlQuery("SELECT * FROM OctopusCloudDatenbank WHERE user = :username_db", username_db=username)
            
        results = testen.fetch(100)

        if not results:
          self.redirect('/')
        else:
          # Nachsehen, ob Credentials für einen Amazon S3 Zugang eingegeben wurden
          testen = db.GqlQuery("SELECT * FROM OctopusCloudDatenbank WHERE user = :username_db AND zugangstyp = :zugangstyp_db", username_db=username, zugangstyp_db="Amazon")
          # Wenn Einträge vorhanden sind, werden sie aus der DB geholt und gelöscht
          results = testen.fetch(100)
          if results:
            # Es gibt schon einen S3 Zugang
            aktuellezone = "Amazon"
            eucalyptusname = "Amazon"
          else:
            # Nachsehen, ob Credentials für einen Eucalyptus Zugang eingegeben wurden
            testen = db.GqlQuery("SELECT * FROM OctopusCloudDatenbank WHERE user = :username_db AND zugangstyp = :zugangstyp_db", username_db=username, zugangstyp_db="Eucalyptus")
            results = testen.fetch(100)
             
            if results:
              # Es gibt einen Eucalyptus (Walrus) Zugang
              aktuellezone = "Eucalyptus"
              # Einen Eucalyptus-Zugang holen
              anzahl = testen.count()   
              for test in results:
                eucalyptusname = str(test.eucalyptusname)
                
            else:
              self.redirect('/')
              
            
        # Connect with storage service
        conn_s3, regionname = logins3(username, aktuellezone)
        
        # Get values from the config file
        # The name of the bucket that is used      
        # The character "@" cannot be used. Therefore we use "at".  
        bucketname = str(parser.get('bucket', 'bucketname'))+str(username).replace('@', 'at').replace('.', '-')
            
        bucket_instance = conn_s3.get_bucket(bucketname)

        

        # Nachsehen, ob eine Sprache ausgewählte wurde und wenn ja, welche Sprache
        sprache = aktuelle_sprache(username)
        navigations_bar = navigations_bar_funktion(sprache)



        url = users.create_logout_url(self.request.uri).replace('&', '&amp;').replace('&amp;amp;', '&amp;')
        url_linktext = 'Logout'



        key_instance = bucket_instance.get_acl(keyname)

        acl = bucket_instance.get_acl(key_name=keyname)
        

        AllUsersREAD  = ''
        AllUsersWRITE = ''
        AllUsersFULL  = ''
        AuthentUsersREAD   = ''
        AuthentUsersWRITE  = ''
        AuthentUsersFULL   = ''
        OwnerName   = ''
        OwnerREAD   = ''
        OwnerWRITE  = ''
        OwnerFULL   = ''

        for grant in acl.acl.grants:
          if str(grant.uri).find('AllUsers') != -1 and grant.permission == 'READ':
            AllUsersREAD  = 'tick.png'
          if str(grant.uri).find('AllUsers') != -1 and grant.permission == 'WRITE':
            AllUsersWRITE = 'tick.png'
          if str(grant.uri).find('AllUsers') != -1 and grant.permission == 'FULL_CONTROL':
            AllUsersREAD  = 'tick.png'
            AllUsersWRITE = 'tick.png'
            AllUsersFULL  = 'tick.png'
          if str(grant.uri).find('AuthenticatedUsers') != -1 and grant.permission == 'READ':
            AuthentUsersREAD  = 'tick.png'
          elif str(grant.uri).find('AuthenticatedUsers') != -1 and grant.permission == 'WRITE':
            AuthentUsersWRITE = 'tick.png'
          elif str(grant.uri).find('AuthenticatedUsers') != -1 and grant.permission == 'FULL_CONTROL':
            AuthentUsersFULL  = 'tick.png'
          # Wenn der Besitzer des Keys dieser Eintrag hier ist...
          if str(key_instance.owner.id) == str(grant.id):
            OwnerName = str(grant.display_name)
            if grant.permission == 'READ':
              OwnerREAD   = 'tick.png'
            if grant.permission == 'WRITE':
              OwnerWRITE  = 'tick.png'
            if grant.permission == 'FULL_CONTROL':
              OwnerREAD   = 'tick.png'
              OwnerWRITE  = 'tick.png'
              OwnerFull   = 'tick.png'

        if AllUsersREAD  == '': AllUsersREAD  = 'delete.png'
        if AllUsersWRITE == '': AllUsersWRITE = 'delete.png'
        if AllUsersFULL  == '': AllUsersFULL  = 'delete.png'
        if AuthentUsersREAD  == '': AuthentUsersREAD  = 'delete.png'
        if AuthentUsersWRITE == '': AuthentUsersWRITE = 'delete.png'
        if AuthentUsersFULL  == '': AuthentUsersFULL  = 'delete.png'
        if OwnerREAD  == '': OwnerREAD  = 'delete.png'
        if OwnerWRITE == '': OwnerWRITE = 'delete.png'
        if OwnerFull  == '': OwnerFull  = 'delete.png'

        acl_tabelle = '\n'
        acl_tabelle = acl_tabelle + '<table border="1" cellspacing="0" cellpadding="5"> \n'
        acl_tabelle = acl_tabelle + '<tr> \n'
        if sprache == "de": 
          acl_tabelle = acl_tabelle + '<th>Benutzer</th> \n'
          acl_tabelle = acl_tabelle + '<th>Lesen</th> \n'
          acl_tabelle = acl_tabelle + '<th>Schreiben</th> \n'
          acl_tabelle = acl_tabelle + '<th>Voller Zugriff</th> \n'
        else:
          acl_tabelle = acl_tabelle + '<th>User</th> \n'
          acl_tabelle = acl_tabelle + '<th>Read</th> \n'
          acl_tabelle = acl_tabelle + '<th>Write</th> \n'
          acl_tabelle = acl_tabelle + '<th>Full Control</th> \n'
        acl_tabelle = acl_tabelle + '</tr> \n'
        acl_tabelle = acl_tabelle + '<tr> \n'
        if sprache == "de": acl_tabelle = acl_tabelle + '<td>Alle</td> \n'
        else:               acl_tabelle = acl_tabelle + '<td>Everyone</td> \n'
        acl_tabelle = acl_tabelle + '<td align="center"> \n'
        acl_tabelle = acl_tabelle + '<img src="bilder/'+AllUsersREAD+'" width="24" height="24" border="0" alt="'+AllUsersREAD+'"> \n'
        acl_tabelle = acl_tabelle + '</td> \n'
        acl_tabelle = acl_tabelle + '<td align="center"> \n'
        acl_tabelle = acl_tabelle + '<img src="bilder/'+AllUsersWRITE+'" width="24" height="24" border="0" alt="'+AllUsersWRITE+'"> \n'
        acl_tabelle = acl_tabelle + '</td> \n'
        acl_tabelle = acl_tabelle + '<td align="center"> \n'
        acl_tabelle = acl_tabelle + '<img src="bilder/'+AllUsersFULL+'" width="24" height="24" border="0" alt="'+AllUsersFULL+'"> \n'
        acl_tabelle = acl_tabelle + '</td> \n'
        acl_tabelle = acl_tabelle + '</tr> \n'
        acl_tabelle = acl_tabelle + '<tr> \n'
        if sprache == "de": acl_tabelle = acl_tabelle + '<td>Authentifizierte Benutzer</td> \n'
        else:               acl_tabelle = acl_tabelle + '<td>Authenticated Users</td> \n'
        acl_tabelle = acl_tabelle + '<td align="center"> \n'
        acl_tabelle = acl_tabelle + '<img src="bilder/'+AuthentUsersREAD+'" width="24" height="24" border="0" alt="'+AuthentUsersREAD+'"> \n'
        acl_tabelle = acl_tabelle + '</td> \n'
        acl_tabelle = acl_tabelle + '<td align="center"> \n'
        acl_tabelle = acl_tabelle + '<img src="bilder/'+AuthentUsersWRITE+'" width="24" height="24" border="0" alt="'+AuthentUsersWRITE+'"> \n'
        acl_tabelle = acl_tabelle + '</td> \n'
        acl_tabelle = acl_tabelle + '<td align="center"> \n'
        acl_tabelle = acl_tabelle + '<img src="bilder/'+AuthentUsersFULL+'" width="24" height="24" border="0" alt="'+AuthentUsersFULL+'"> \n'
        acl_tabelle = acl_tabelle + '</td> \n'
        acl_tabelle = acl_tabelle + '</tr> \n'
        acl_tabelle = acl_tabelle + '<tr> \n'
        if sprache == "de": acl_tabelle = acl_tabelle + '<td>'+OwnerName+' (Besitzer)</td> \n'
        else:               acl_tabelle = acl_tabelle + '<td>'+OwnerName+' Owner</td> \n'
        acl_tabelle = acl_tabelle + '<td align="center"> \n'
        acl_tabelle = acl_tabelle + '<img src="bilder/'+OwnerREAD+'" width="24" height="24" border="0" alt="'+OwnerREAD+'"> \n'
        acl_tabelle = acl_tabelle + '</td> \n'
        acl_tabelle = acl_tabelle + '<td align="center"> \n'
        acl_tabelle = acl_tabelle + '<img src="bilder/'+OwnerWRITE+'" width="24" height="24" border="0" alt="'+OwnerWRITE+'"> \n'
        acl_tabelle = acl_tabelle + '</td> \n'
        acl_tabelle = acl_tabelle + '<td align="center"> \n'
        acl_tabelle = acl_tabelle + '<img src="bilder/'+OwnerFull+'" width="24" height="24" border="0" alt="'+OwnerFull+'"> \n'
        acl_tabelle = acl_tabelle + '</td> \n'
        acl_tabelle = acl_tabelle + '</tr> \n'
        acl_tabelle = acl_tabelle + '</table> \n'


        template_values = {
        'navigations_bar': navigations_bar,
        'url': url,
        'url_linktext': url_linktext,
        'keyname': keyname,
        'acl_tabelle': acl_tabelle,
        'md5hash': md5hash
        }


        path = os.path.join(os.path.dirname(__file__), "../templates", sprache, "acl.html")
        self.response.out.write(template.render(path,template_values))
Ejemplo n.º 16
0
    def get(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        # self.response.out.write('posted!')
        # Den Usernamen erfahren
        username = users.get_current_user()
        if not username:
            self.redirect('/')
        # Eventuell vorhande Fehlermeldung holen
        message = self.request.get('message')
        # Namen des Buckets holen, dessen Inhalt angezeigt wird
        bucketname = self.request.get('bucket')

        # Nachsehen, ob eine Region/Zone ausgewählte wurde
        aktivezone = db.GqlQuery(
            "SELECT * FROM KoalaCloudDatenbankAktiveZone WHERE user = :username_db",
            username_db=username)
        results = aktivezone.fetch(100)

        if not results:
            self.redirect('/')
        else:
            # Nachsehen, ob eine Sprache ausgewählte wurde und wenn ja, welche Sprache
            sprache = aktuelle_sprache(username)
            navigations_bar = navigations_bar_funktion(sprache, mobile)

            results = aktivezone.fetch(100)

            url = users.create_logout_url(self.request.uri).replace(
                '&', '&amp;').replace('&amp;amp;', '&amp;')
            #url = users.create_logout_url(self.request.uri)
            url_linktext = 'Logout'

            conn_region, regionname = login(username)
            zone_amazon = amazon_region(username)
            zugangstyp = zugangstyp_erhalten(username)

            zonen_liste = zonen_liste_funktion(username, sprache, mobile)

            if sprache != "de":
                sprache = "en"

            input_error_message = error_messages.get(message, {}).get(sprache)

            # Wenn keine Fehlermeldung gefunden wird, ist das Ergebnis "None"
            if input_error_message == None:
                input_error_message = ""

            # Wenn die Nachricht grün formatiert werden soll...
            if message in ("111", "118", "120"):
                # wird sie hier, in der Hilfsfunktion grün formatiert
                input_error_message = format_error_message_green(
                    input_error_message)
            # Ansonsten wird die Nachricht rot formatiert
            elif message in ("112", "119", "121"):
                input_error_message = format_error_message_red(
                    input_error_message)
            else:
                input_error_message = ""

            AWSAccessKeyId = aws_access_key_erhalten(username, regionname)
            AWSSecretAccessKeyId = aws_secret_access_key_erhalten(
                username, regionname)

            # Mit S3 verbinden
            conn_s3 = logins3(username)

            try:
                # Liste der Buckets
                bucket_instance = conn_s3.get_bucket(bucketname)
            except:
                # Wenn es nicht klappt...
                if sprache == "de":
                    bucket_keys_tabelle = '<font color="red">Es ist zu einem Fehler gekommen</font>'
                else:
                    bucket_keys_tabelle = '<font color="red">An error occured</font>'
                laenge_liste_keys = 0
                # Wenn es geklappt hat...
            else:
                try:
                    # Liste der Keys
                    liste_keys = bucket_instance.get_all_keys()
                except:
                    # Wenn es nicht klappt...
                    if sprache == "de":
                        bucket_keys_tabelle = '<font color="red">Es ist zu einem Fehler gekommen</font>'
                    else:
                        bucket_keys_tabelle = '<font color="red">An error occured</font>'
                    laenge_liste_keys = 0
                else:
                    # Wenn es geklappt hat...
                    # Anzahl der Keys in der Liste
                    laenge_liste_keys = len(liste_keys)

                # Wenn wir in einer Eucalyputs-Infrastruktur sind, dann muss dieser
                # dämliche None-Eintrag weg
                if regionname != "Amazon":
                    liste_keys2 = []
                    for i in range(laenge_liste_keys):
                        if str(liste_keys[i].name) != 'None':
                            liste_keys2.append(liste_keys[i])
                    laenge_liste_keys2 = len(liste_keys2)
                    laenge_liste_keys = laenge_liste_keys2
                    liste_keys = liste_keys2

                if laenge_liste_keys == 0:
                    if sprache == "de":
                        bucket_keys_tabelle = 'Der Bucket <B>' + bucketname + ' </B>ist leer.'
                    else:
                        bucket_keys_tabelle = 'The bucket <B>' + bucketname + ' </B>is empty.'
                else:

                    if mobile == "true":
                        # mobile version...

                        bucket_keys_tabelle = ''
                        bucket_keys_tabelle += '<table border="0" cellspacing="0" cellpadding="5" width="300">'

                        counter = 0
                        for i in range(laenge_liste_keys):

                            if counter > 0:
                                bucket_keys_tabelle += '<tr><td colspan="3">&nbsp;</td></tr>'
                            counter += 1

                            bucket_keys_tabelle += '<tr>'
                            if liste_keys[
                                    i].name == None and regionname != "Amazon":
                                bucket_keys_tabelle += '<td>&nbsp;</td>'
                            else:
                                bucket_keys_tabelle += '<td>'
                                bucket_keys_tabelle += '<a href="/bucketkeyentfernen?bucket='
                                bucket_keys_tabelle += str(bucketname)
                                bucket_keys_tabelle += '&amp;typ=pur'
                                bucket_keys_tabelle += '&amp;key='
                                bucket_keys_tabelle += str(liste_keys[i].name)
                                bucket_keys_tabelle += "&amp;mobile="
                                bucket_keys_tabelle += str(mobile)
                                if sprache == "de":
                                    bucket_keys_tabelle += '" title="Key l&ouml;schen"><img src="bilder/delete.png" width="16" height="16" border="0" alt="Key l&ouml;schen"></a>'
                                else:
                                    bucket_keys_tabelle += '" title="erase key"><img src="bilder/delete.png" width="16" height="16" border="0" alt="erase key"></a>'
                                bucket_keys_tabelle += '</td>'

                            bucket_keys_tabelle += '<td colspan="2" align="left">'
                            bucket_keys_tabelle += '<a href="'
                            if regionname == "Amazon":
                                bucket_keys_tabelle += liste_keys[
                                    i].generate_url(600,
                                                    method='GET',
                                                    headers=None,
                                                    query_auth=True,
                                                    force_http=True).replace(
                                                        '&', '&amp;').replace(
                                                            '&amp;amp;',
                                                            '&amp;')
                            else:
                                port = port_erhalten(username, regionname)
                                bucket_keys_tabelle += liste_keys[
                                    i].generate_url(
                                        600,
                                        method='GET',
                                        headers=None,
                                        query_auth=True,
                                        force_http=True).replace(
                                            '&', '&amp;').replace(
                                                '&amp;amp;', '&amp;').replace(
                                                    '/services/Walrus/',
                                                    ':' + str(port) +
                                                    '/services/Walrus/')
                            bucket_keys_tabelle += '">'
                            bucket_keys_tabelle += str(liste_keys[i].name)
                            bucket_keys_tabelle += '</a>'
                            bucket_keys_tabelle += '</td>'

                            bucket_keys_tabelle += '</tr>'
                            bucket_keys_tabelle += '<tr>'
                            if sprache == "de":
                                bucket_keys_tabelle += '<td align="right" colspan="2"><b>Gr&ouml;&szlig;e:</b></td>'
                            else:
                                bucket_keys_tabelle += '<td align="right" colspan="2"><b>Size:</b></td>'
                            bucket_keys_tabelle += '<td align="left">'
                            if liste_keys[
                                    i].name == None and regionname != "Amazon":
                                bucket_keys_tabelle += '&nbsp;'
                            else:
                                bucket_keys_tabelle += str(liste_keys[i].size)
                            bucket_keys_tabelle += '</td>'

                            bucket_keys_tabelle += '</tr>'
                            bucket_keys_tabelle += '<tr>'

                            if sprache == "de":
                                bucket_keys_tabelle += '<td align="right" colspan="2"><b>Datum:</b></td>'
                            else:
                                bucket_keys_tabelle += '<td align="right" colspan="2"><b>Date:</b></td>'
                            bucket_keys_tabelle += '<td align="left">'
                            # Den ISO8601 Zeitstring umwandeln, damit es besser aussieht.
                            if liste_keys[
                                    i].name == None and regionname != "Amazon":
                                bucket_keys_tabelle += '&nbsp;'
                            else:
                                datum_der_letzten_aenderung = parse(
                                    liste_keys[i].last_modified)
                                bucket_keys_tabelle += str(
                                    datum_der_letzten_aenderung.strftime(
                                        "%Y-%m-%d  %H:%M:%S"))
                            bucket_keys_tabelle += '</td>'

                            bucket_keys_tabelle += '</tr>'
                            bucket_keys_tabelle += '<tr>'

                            bucket_keys_tabelle += '<td align="right" colspan="2"><b>ACL:</b></td>'
                            bucket_keys_tabelle += '<td align="left">'
                            bucket_keys_tabelle += '<a href="/acl_einsehen?bucket='
                            bucket_keys_tabelle += str(bucketname)
                            bucket_keys_tabelle += '&amp;typ=pur'
                            bucket_keys_tabelle += '&amp;key='
                            bucket_keys_tabelle += str(liste_keys[i].name)
                            bucket_keys_tabelle += "&amp;mobile="
                            bucket_keys_tabelle += str(mobile)
                            if sprache == "de":
                                bucket_keys_tabelle += '" title="einsehen/&auml;ndern">einsehen/&auml;ndern</a>'
                            else:
                                bucket_keys_tabelle += '" title="view/edit">view/edit</a>'
                            bucket_keys_tabelle += '</td>'

                            bucket_keys_tabelle += '</tr>'
                            bucket_keys_tabelle += '<tr>'

                            # In S3 and Google Storage, each MD5 checksum is enclosed by double quotes.
                            # Eliminate them with .replace('"','')
                            bucket_keys_tabelle += '<td align="right" colspan="2"><b>MD5:</b></td>'
                            bucket_keys_tabelle += '<td align="left">' + str(
                                liste_keys[i].etag.replace('"', '')) + '</td>'
                            bucket_keys_tabelle += '</tr>'
                        bucket_keys_tabelle += '</table>'

                    else:
                        # not the mobile version

                        bucket_keys_tabelle = ''
                        bucket_keys_tabelle += '<table border="0" cellspacing="0" cellpadding="5">'

                        counter = 0
                        for i in range(laenge_liste_keys):

                            if counter > 0:
                                bucket_keys_tabelle += '<tr><td colspan="4">&nbsp;</td></tr>'
                            counter += 1

                            bucket_keys_tabelle += '<tr>'
                            if liste_keys[
                                    i].name == None and regionname != "Amazon":
                                bucket_keys_tabelle += '<td>&nbsp;</td>'
                            else:
                                bucket_keys_tabelle += '<td align="left" bgcolor="#D4D4D4">'
                                bucket_keys_tabelle += '<a href="/bucketkeyentfernen?bucket='
                                bucket_keys_tabelle += str(bucketname)
                                bucket_keys_tabelle += '&amp;typ=pur'
                                bucket_keys_tabelle += '&amp;key='
                                bucket_keys_tabelle += str(liste_keys[i].name)
                                bucket_keys_tabelle += "&amp;mobile="
                                bucket_keys_tabelle += str(mobile)
                                if sprache == "de":
                                    bucket_keys_tabelle += '" title="Key l&ouml;schen"><img src="bilder/delete.png" width="16" height="16" border="0" alt="Key l&ouml;schen"></a>'
                                else:
                                    bucket_keys_tabelle += '" title="erase key"><img src="bilder/delete.png" width="16" height="16" border="0" alt="erase key"></a>'
                                bucket_keys_tabelle += '</td>'

                            bucket_keys_tabelle += '<td colspan="3" align="left" bgcolor="#D4D4D4">&nbsp;</td>'

                            bucket_keys_tabelle += '</tr>'
                            bucket_keys_tabelle += '<tr>'

                            bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>ID:</b></td>'
                            bucket_keys_tabelle += '<td colspan="3" align="left">'
                            bucket_keys_tabelle += '<a href="'
                            if regionname == "Amazon":
                                bucket_keys_tabelle += liste_keys[
                                    i].generate_url(600,
                                                    method='GET',
                                                    headers=None,
                                                    query_auth=True,
                                                    force_http=True).replace(
                                                        '&', '&amp;').replace(
                                                            '&amp;amp;',
                                                            '&amp;')
                            else:
                                port = port_erhalten(username, regionname)
                                bucket_keys_tabelle += liste_keys[
                                    i].generate_url(
                                        600,
                                        method='GET',
                                        headers=None,
                                        query_auth=True,
                                        force_http=True).replace(
                                            '&', '&amp;').replace(
                                                '&amp;amp;', '&amp;').replace(
                                                    '/services/Walrus/',
                                                    ':' + str(port) +
                                                    '/services/Walrus/')
                            bucket_keys_tabelle += '">'
                            bucket_keys_tabelle += str(liste_keys[i].name)
                            bucket_keys_tabelle += '</a>'
                            bucket_keys_tabelle += '</td>'

                            bucket_keys_tabelle += '</tr>'
                            bucket_keys_tabelle += '<tr>'
                            if sprache == "de":
                                bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>Gr&ouml;&szlig;e:</b></td>'
                            else:
                                bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>Size:</b></td>'
                            bucket_keys_tabelle += '<td align="left">'
                            if liste_keys[
                                    i].name == None and regionname != "Amazon":
                                bucket_keys_tabelle += '&nbsp;'
                            else:
                                bucket_keys_tabelle += str(liste_keys[i].size)
                            bucket_keys_tabelle += '</td>'

                            if sprache == "de":
                                bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>Datum:</b></td>'
                            else:
                                bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>Date:</b></td>'
                            bucket_keys_tabelle += '<td align="left">'
                            # Den ISO8601 Zeitstring umwandeln, damit es besser aussieht.
                            if liste_keys[
                                    i].name == None and regionname != "Amazon":
                                bucket_keys_tabelle += '&nbsp;'
                            else:
                                datum_der_letzten_aenderung = parse(
                                    liste_keys[i].last_modified)
                                bucket_keys_tabelle += str(
                                    datum_der_letzten_aenderung.strftime(
                                        "%Y-%m-%d  %H:%M:%S"))
                            bucket_keys_tabelle += '</td>'

                            bucket_keys_tabelle += '</tr>'
                            bucket_keys_tabelle += '<tr>'

                            bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>ACL:</b></td>'
                            bucket_keys_tabelle += '<td align="left">'
                            bucket_keys_tabelle += '<a href="/acl_einsehen?bucket='
                            bucket_keys_tabelle += str(bucketname)
                            bucket_keys_tabelle += '&amp;typ=pur'
                            bucket_keys_tabelle += '&amp;key='
                            bucket_keys_tabelle += str(liste_keys[i].name)
                            bucket_keys_tabelle += "&amp;mobile="
                            bucket_keys_tabelle += str(mobile)
                            if sprache == "de":
                                bucket_keys_tabelle += '" title="einsehen/&auml;ndern">einsehen/&auml;ndern</a>'
                            else:
                                bucket_keys_tabelle += '" title="view/edit">view/edit</a>'
                            bucket_keys_tabelle += '</td>'

                            # In S3 and Google Storage, each MD5 checksum is enclosed by double quotes.
                            # Eliminate them with .replace('"','')
                            bucket_keys_tabelle += '<td align="right" bgcolor="#D4D4D4"><b>MD5:</b></td>'
                            bucket_keys_tabelle += '<td align="left">' + str(
                                liste_keys[i].etag.replace('"', '')) + '</td>'
                            bucket_keys_tabelle += '</tr>'
                        bucket_keys_tabelle += '</table>'

            # Wenn man sich NICHT unter Amazon befindet, funktioniert der Download von Keys nicht.
#          if regionname != "Amazon":
#            if sprache == "de":
#              eucalyptus_warnung = '<B>Achtung!</B> Unter Eucalyptus 1.6 und 1.6.1 funktioniert der Download von Keys nicht. Dabei handelt es sich um einen Fehler von Eucalyptus. Es kommt zu dieser Fehlermeldung: <B>Failure: 500 Internal Server Error</B>'
#            else:
#              eucalyptus_warnung = '<B>Attention!</B> With Eucalyptus 1.6 and 1.6.1 the download of Keys is broken. This is a bug of Eucalyptus. The result is this error message: <B>Failure: 500 Internal Server Error</B>'
#          else:
#            eucalyptus_warnung = ''

#Dokumentation zum Upload von Keys
#http://docs.amazonwebservices.com/AmazonS3/latest/index.html?HTTPPOSTForms.html
#http://doc.s3.amazonaws.com/proposals/post.html
#http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1434
#http://s3.amazonaws.com/doc/s3-example-code/post/post_sample.html

# Hier wird das Policy-Dokument erzeugt
            policy_document = ''
            policy_document = policy_document + '{'
            policy_document = policy_document + '"expiration": "2100-01-01T00:00:00Z",'
            policy_document = policy_document + '"conditions": ['
            policy_document = policy_document + '{"bucket": "' + bucketname + '"}, '
            policy_document = policy_document + '["starts-with", "$acl", ""],'
            if mobile == "true":
                policy_document = policy_document + '{"success_action_redirect": "http://koalacloud.appspot.com/bucket_inhalt_pure?mobile=true"},'
            else:
                policy_document = policy_document + '{"success_action_redirect": "http://koalacloud.appspot.com/bucket_inhalt_pure?mobile=false"},'
            policy_document = policy_document + '["starts-with", "$key", ""],'
            policy_document = policy_document + '["starts-with", "$Content-Type", ""]'
            policy_document = policy_document + ']'
            policy_document = policy_document + '}'

            policy = base64.b64encode(policy_document)

            signature = base64.b64encode(
                hmac.new(AWSSecretAccessKeyId, policy, sha).digest())

            keys_upload_formular = ''
            if zugangstyp == "Eucalyptus":
                endpointurl = endpointurl_erhalten(username, regionname)
                port = port_erhalten(username, regionname)
                keys_upload_formular += '<form action="http://' + str(
                    endpointurl
                ) + ':' + str(
                    port
                ) + '/services/Walrus/' + bucketname + '" method="post" enctype="multipart/form-data">\n'
            elif zugangstyp == "GoogleStorage":
                keys_upload_formular += '<form action="http://commondatastorage.googleapis.com/' + bucketname + '" method="post" enctype="multipart/form-data">\n'
            elif zugangstyp == "HostEuropeCloudStorage":
                keys_upload_formular += '<form action="http://' + bucketname + '.cs.hosteurope.de'
                keys_upload_formular += '" method="post" enctype="multipart/form-data">\n'
            elif zugangstyp == "DunkelCloudStorage":
                keys_upload_formular += '<form action="http://' + bucketname + '.dcs.dunkel.de'
                keys_upload_formular += '" method="post" enctype="multipart/form-data">\n'
            else:
                keys_upload_formular += '<form action="http://s3.amazonaws.com/' + bucketname + '" method="post" enctype="multipart/form-data">\n'

            if mobile == "true":
                # mobile version...
                keys_upload_formular += '<table border="0" cellspacing="0" cellpadding="5">\n'
                keys_upload_formular += '<tr>\n'
                keys_upload_formular += '<td>\n'
                keys_upload_formular += '<input type="hidden" name="key" value="${filename}">\n'
                keys_upload_formular += '<select name="acl" size="1">\n'
                keys_upload_formular += '<option selected="selected">public-read</option>\n'
                keys_upload_formular += '<option>private</option>\n'
                keys_upload_formular += '<option>public-read-write</option>\n'
                keys_upload_formular += '<option>authenticated-read</option>\n'
                keys_upload_formular += '</select>\n'
                keys_upload_formular += '</td>'
                keys_upload_formular += '</tr>'
                keys_upload_formular += '<tr>'
                keys_upload_formular += '<td>'
                keys_upload_formular += '<select name="Content-Type" size="1">\n'
                keys_upload_formular += '<option selected="selected">application/octet-stream</option>\n'
                keys_upload_formular += '<option>application/pdf</option>\n'
                keys_upload_formular += '<option>application/zip</option>\n'
                keys_upload_formular += '<option>audio/mp4</option>\n'
                keys_upload_formular += '<option>audio/mpeg</option>\n'
                keys_upload_formular += '<option>audio/ogg</option>\n'
                keys_upload_formular += '<option>audio/vorbis</option>\n'
                keys_upload_formular += '<option>image/gif</option>\n'
                keys_upload_formular += '<option>image/jpeg</option>\n'
                keys_upload_formular += '<option>image/png</option>\n'
                keys_upload_formular += '<option>image/tiff</option>\n'
                keys_upload_formular += '<option>text/html</option>\n'
                keys_upload_formular += '<option>text/plain</option>\n'
                keys_upload_formular += '<option>video/mp4</option>\n'
                keys_upload_formular += '<option>video/mpeg</option>\n'
                keys_upload_formular += '<option>video/ogg</option>\n'
                keys_upload_formular += '</select>\n'
                keys_upload_formular += '</td>'
                keys_upload_formular += '</tr>'
                keys_upload_formular += '<tr>'
                keys_upload_formular += '<td>\n'
                keys_upload_formular += '<input type="hidden" name="success_action_redirect" value="http://koalacloud.appspot.com/bucket_inhalt_pure?mobile=true">\n'
                keys_upload_formular += '<input type="hidden" name="AWSAccessKeyId" value="' + AWSAccessKeyId + '">\n'
                keys_upload_formular += '<input type="hidden" name="policy" value="' + policy + '">\n'
                keys_upload_formular += '<input type="hidden" name="signature" value="' + signature + '">\n'
                keys_upload_formular += '<input type="file" name="file" size="20">\n'
                keys_upload_formular += '</td>'
                keys_upload_formular += '</tr>'
                keys_upload_formular += '<tr>'
                keys_upload_formular += '<td>'
                if sprache == "de":
                    keys_upload_formular += '<input type="submit" value="Objekt in den Bucket hochladen">\n'
                else:
                    keys_upload_formular += '<input type="submit" value="upload objekt into bucket">\n'
                keys_upload_formular += '</td>'
                keys_upload_formular += '</tr>'
                keys_upload_formular += '</table>'
                keys_upload_formular += '</form>'
            else:
                # Not the mobile version
                keys_upload_formular += '<table border="0" cellspacing="0" cellpadding="5">'
                keys_upload_formular += '<tr>'
                keys_upload_formular += '<td>'
                keys_upload_formular += '<input type="hidden" name="key" value="${filename}">\n'
                keys_upload_formular += '<select name="acl" size="1">\n'
                keys_upload_formular += '<option selected="selected">public-read</option>\n'
                keys_upload_formular += '<option>private</option>\n'
                keys_upload_formular += '<option>public-read-write</option>\n'
                keys_upload_formular += '<option>authenticated-read</option>\n'
                keys_upload_formular += '</select>\n'
                keys_upload_formular += '<select name="Content-Type" size="1">\n'
                keys_upload_formular += '<option selected="selected">application/octet-stream</option>\n'
                keys_upload_formular += '<option>application/pdf</option>\n'
                keys_upload_formular += '<option>application/zip</option>\n'
                keys_upload_formular += '<option>audio/mp4</option>\n'
                keys_upload_formular += '<option>audio/mpeg</option>\n'
                keys_upload_formular += '<option>audio/ogg</option>\n'
                keys_upload_formular += '<option>audio/vorbis</option>\n'
                keys_upload_formular += '<option>image/gif</option>\n'
                keys_upload_formular += '<option>image/jpeg</option>\n'
                keys_upload_formular += '<option>image/png</option>\n'
                keys_upload_formular += '<option>image/tiff</option>\n'
                keys_upload_formular += '<option>text/html</option>\n'
                keys_upload_formular += '<option>text/plain</option>\n'
                keys_upload_formular += '<option>video/mp4</option>\n'
                keys_upload_formular += '<option>video/mpeg</option>\n'
                keys_upload_formular += '<option>video/ogg</option>\n'
                keys_upload_formular += '</select>\n'
                keys_upload_formular += '</td>'
                keys_upload_formular += '</tr>'
                keys_upload_formular += '<tr>'
                keys_upload_formular += '<td>\n'
                keys_upload_formular += '<input type="hidden" name="success_action_redirect" value="http://koalacloud.appspot.com/bucket_inhalt_pure?mobile=false">\n'
                keys_upload_formular += '<input type="hidden" name="AWSAccessKeyId" value="' + AWSAccessKeyId + '">\n'
                keys_upload_formular += '<input type="hidden" name="policy" value="' + policy + '">\n'
                keys_upload_formular += '<input type="hidden" name="signature" value="' + signature + '">\n'
                keys_upload_formular += '<input type="file" name="file" size="60">\n'
                keys_upload_formular += '</td>'
                keys_upload_formular += '</tr>'
                keys_upload_formular += '<tr>'
                keys_upload_formular += '<td>'
                if sprache == "de":
                    keys_upload_formular += '<input type="submit" value="Objekt in den Bucket hochladen">\n'
                else:
                    keys_upload_formular += '<input type="submit" value="upload objekt into bucket">\n'
                keys_upload_formular += '</td>'
                keys_upload_formular += '</tr>'
                keys_upload_formular += '</table>'
                keys_upload_formular += '</form>'

            # Unter Eucalyptus funktioniert das Hochladen von Keys nicht
            #else:
            #  if sprache == "de":
            #    keys_upload_formular = '<p>&nbsp;</p>\n Das Hochladen von Keys funktioniert unter Eucalyptus noch nicht'
            #  else:
            #    keys_upload_formular = '<p>&nbsp;</p>\n The key upload is still not working with Eucaplyptus'

            if laenge_liste_keys != 0:
                alle_keys_loeschen_button = '<p>&nbsp;</p>\n'
                alle_keys_loeschen_button += '<form action="/alle_keys_loeschen" method="get">\n'
                alle_keys_loeschen_button += '<input type="hidden" name="mobile" value="' + mobile + '">'
                alle_keys_loeschen_button += '<input type="hidden" name="s3_ansicht" value="pur"> \n'
                alle_keys_loeschen_button += '<input type="hidden" name="bucket_name" value="' + bucketname + '"> \n'
                if sprache == "de":
                    alle_keys_loeschen_button += '<input type="submit" value="Alle Objekte l&ouml;schen">\n'
                else:
                    alle_keys_loeschen_button += '<input type="submit" value="Erase all objects">\n'
                alle_keys_loeschen_button += '</form>\n'
            else:
                alle_keys_loeschen_button = ''

            path = '&amp;path=bucket_inhalt_pure&amp;bucket=' + bucketname + '&amp;mobile=' + mobile

            template_values = {
                'navigations_bar': navigations_bar,
                'url': url,
                'url_linktext': url_linktext,
                'zone': regionname,
                'zone_amazon': zone_amazon,
                'zonen_liste': zonen_liste,
                'bucket_keys_tabelle': bucket_keys_tabelle,
                'input_error_message': input_error_message,
                'bucketname': bucketname,
                'keys_upload_formular': keys_upload_formular,
                #'eucalyptus_warnung': eucalyptus_warnung,
                'alle_keys_loeschen_button': alle_keys_loeschen_button,
                'mobile': mobile,
                'path': path,
            }

            if mobile == "true":
                path = os.path.join(os.path.dirname(__file__),
                                    "../templates/mobile", sprache,
                                    "s3_keys_pur.html")
            else:
                path = os.path.join(os.path.dirname(__file__), "../templates",
                                    sprache, "s3_keys_pur.html")
            self.response.out.write(template.render(path, template_values))
Ejemplo n.º 17
0
    def get(self):
        # Get the username
        username = users.get_current_user()
        if not username:
            # If no user is logged in, jump back to root
            self.redirect('/')

        # Datastore query that checks if any credentials for this user exist
        testen = db.GqlQuery(
            "SELECT * FROM OctopusCloudDatenbank WHERE user = :username_db",
            username_db=username)

        results = testen.fetch(100)

        if not results:
            # If no credentials exist, jump back to root
            self.redirect('/')
        else:
            # How many entries of this user exist?
            anzahl = testen.count()

            # Walk though every entry (storage service credentials) of this user
            for i in results:
                regionname = str(i.regionname)
                endpointurl = str(i.endpointurl)
                accesskey = str(i.accesskey)
                zugangstyp = str(i.zugangstyp)
                eucalyptusname = str(i.eucalyptusname)

                if regionname == "Amazon":
                    # If we are working with Amazon S3 now...
                    aktuellezone = "Amazon"
                else:
                    # If we are working with Walrus (Eucalyptus) now...
                    aktuellezone = "Eucalyptus"

                # Connect with storage service
                conn_s3, regionname = logins3(username, aktuellezone)

                # Get values from the config file
                # The name of the bucket that is used
                # The character "@" cannot be used. Therefore we use "at".
                bucketname = str(parser.get(
                    'bucket', 'bucketname')) + str(username).replace(
                        '@', 'at').replace('.', '-')

                try:
                    # Connect with bucket
                    bucket_instance = conn_s3.get_bucket(bucketname)
                except:
                    # When it didn't work
                    if sprache == "de":
                        bucket_keys_tabelle = '<font color="red">Es ist zu einem Fehler gekommen</font>'
                    else:
                        bucket_keys_tabelle = '<font color="red">An error occured</font>'
                    laenge_liste_keys = 0
                else:
                    # When it worked...
                    try:
                        # Get a list of all keys inside the bucket
                        liste_keys = bucket_instance.get_all_keys()
                    except:
                        # When it didn't work
                        if sprache == "de":
                            bucket_keys_tabelle = '<font color="red">Es ist zu einem Fehler gekommen</font>'
                        else:
                            bucket_keys_tabelle = '<font color="red">An error occured</font>'
                        laenge_liste_keys = 0
                    else:
                        # When it worked...
                        # Number of keys inside the list
                        laenge_liste_keys = len(liste_keys)

                # When using Walrus (Eucalyptus), we need to erase the stupid "None" entry.
                if aktuellezone != "Amazon":
                    liste_keys2 = []
                    for i in range(laenge_liste_keys):
                        if str(liste_keys[i].name) != 'None':
                            liste_keys2.append(liste_keys[i])
                    laenge_liste_keys2 = len(liste_keys2)
                    laenge_liste_keys = laenge_liste_keys2
                    liste_keys = liste_keys2

                for i in range(laenge_liste_keys):
                    try:
                        # Try to erase the key
                        liste_keys[i].delete()
                    except:
                        fehlermeldung = "121"
                        # If it didn't work ...
                        self.redirect('/s3?message=' + fehlermeldung)
                    else:
                        fehlermeldung = "120"
                        # It the key was erased...
                        self.redirect('/s3?message=' + fehlermeldung)
Ejemplo n.º 18
0
    def get(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        # Den Usernamen erfahren
        username = users.get_current_user()
        if not username:
          self.redirect('/')
        # Namen des Buckets holen, in dem der Key ist
        bucketname = self.request.get('bucket')
        # Namen des Keys holen, dessen ACL angezeigt wird
        keyname = self.request.get('key')
        # War es die reine S3-Darstellung oder die Komfort-Darstellung, aus der die 
        # Anfrage zu Löschen des Keys kam?
        typ = self.request.get('typ')
        # Verzeichnis holen, wenn es die Komfort-Ansicht war
        directory = self.request.get('dir')

        # Nachsehen, ob eine Region/Zone ausgewählte wurde
        aktivezone = db.GqlQuery("SELECT * FROM KoalaCloudDatenbankAktiveZone WHERE user = :username_db", username_db=username)
        results = aktivezone.fetch(100)

        if not results:
          self.redirect('/')
        else:
          # Nachsehen, ob eine Sprache ausgewählte wurde und wenn ja, welche Sprache
          sprache = aktuelle_sprache(username)
          navigations_bar = navigations_bar_funktion(sprache,mobile)

          results = aktivezone.fetch(100)

          url = users.create_logout_url(self.request.uri).replace('&', '&amp;').replace('&amp;amp;', '&amp;')
          url_linktext = 'Logout'

          conn_region, regionname = login(username)
          zone_amazon = amazon_region(username)

          zonen_liste = zonen_liste_funktion(username,sprache,mobile)

          # Mit S3 verbinden
          conn_s3 = logins3(username)
          bucket_instance = conn_s3.get_bucket(bucketname)

          key_instance = bucket_instance.get_acl(keyname)

          acl = bucket_instance.get_acl(key_name=keyname)

          AllUsersREAD  = ''
          AllUsersWRITE = ''
          AllUsersFULL  = ''
          AuthentUsersREAD   = ''
          AuthentUsersWRITE  = ''
          AuthentUsersFULL   = ''
          OwnerName   = ''
          OwnerREAD   = ''
          OwnerWRITE  = ''
          OwnerFULL   = ''

          for grant in acl.acl.grants:
            if str(grant.uri).find('AllUsers') != -1 and grant.permission == 'READ':
              AllUsersREAD  = 'tick.png'
            if str(grant.uri).find('AllUsers') != -1 and grant.permission == 'WRITE':
              AllUsersWRITE = 'tick.png'
            if str(grant.uri).find('AllUsers') != -1 and grant.permission == 'FULL_CONTROL':
              AllUsersREAD  = 'tick.png'
              AllUsersWRITE = 'tick.png'
              AllUsersFULL  = 'tick.png'
            if str(grant.uri).find('AuthenticatedUsers') != -1 and grant.permission == 'READ':
              AuthentUsersREAD  = 'tick.png'
            elif str(grant.uri).find('AuthenticatedUsers') != -1 and grant.permission == 'WRITE':
              AuthentUsersWRITE = 'tick.png'
            elif str(grant.uri).find('AuthenticatedUsers') != -1 and grant.permission == 'FULL_CONTROL':
              AuthentUsersFULL  = 'tick.png'
            # Wenn der Besitzer des Keys dieser Eintrag hier ist...
            if str(key_instance.owner.id) == str(grant.id):
              OwnerName = str(grant.display_name)
              if grant.permission == 'READ':
                OwnerREAD   = 'tick.png'
              if grant.permission == 'WRITE':
                OwnerWRITE  = 'tick.png'
              if grant.permission == 'FULL_CONTROL':
                OwnerREAD   = 'tick.png'
                OwnerWRITE  = 'tick.png'
                OwnerFull   = 'tick.png'

          if AllUsersREAD  == '': AllUsersREAD  = 'delete.png'
          if AllUsersWRITE == '': AllUsersWRITE = 'delete.png'
          if AllUsersFULL  == '': AllUsersFULL  = 'delete.png'
          if AuthentUsersREAD  == '': AuthentUsersREAD  = 'delete.png'
          if AuthentUsersWRITE == '': AuthentUsersWRITE = 'delete.png'
          if AuthentUsersFULL  == '': AuthentUsersFULL  = 'delete.png'
          if OwnerREAD  == '': OwnerREAD  = 'delete.png'
          if OwnerWRITE == '': OwnerWRITE = 'delete.png'
          if OwnerFull  == '': OwnerFull  = 'delete.png'

          acl_tabelle = '\n'
          acl_tabelle = acl_tabelle + '<table border="0" cellspacing="0" cellpadding="5"> \n'
          acl_tabelle = acl_tabelle + '<tr> \n'
          if sprache == "de": 
            acl_tabelle = acl_tabelle + '<th align="left">Benutzer</th> \n'
            acl_tabelle = acl_tabelle + '<th align="center">Lesen</th> \n'
            acl_tabelle = acl_tabelle + '<th align="center">Schreiben</th> \n'
            acl_tabelle = acl_tabelle + '<th align="center">Voller Zugriff</th> \n'
          else:
            acl_tabelle = acl_tabelle + '<th align="left">User</th> \n'
            acl_tabelle = acl_tabelle + '<th align="center">Read</th> \n'
            acl_tabelle = acl_tabelle + '<th align="center">Write</th> \n'
            acl_tabelle = acl_tabelle + '<th align="center">Full Control</th> \n'
          acl_tabelle = acl_tabelle + '</tr> \n'
          acl_tabelle = acl_tabelle + '<tr> \n'
          if sprache == "de": acl_tabelle = acl_tabelle + '<td>Alle</td> \n'
          else:               acl_tabelle = acl_tabelle + '<td>Everyone</td> \n'
          acl_tabelle = acl_tabelle + '<td align="center"> \n'
          acl_tabelle = acl_tabelle + '<img src="bilder/'+AllUsersREAD+'" width="24" height="24" border="0" alt="'+AllUsersREAD+'"> \n'
          acl_tabelle = acl_tabelle + '</td> \n'
          acl_tabelle = acl_tabelle + '<td align="center"> \n'
          acl_tabelle = acl_tabelle + '<img src="bilder/'+AllUsersWRITE+'" width="24" height="24" border="0" alt="'+AllUsersWRITE+'"> \n'
          acl_tabelle = acl_tabelle + '</td> \n'
          acl_tabelle = acl_tabelle + '<td align="center"> \n'
          acl_tabelle = acl_tabelle + '<img src="bilder/'+AllUsersFULL+'" width="24" height="24" border="0" alt="'+AllUsersFULL+'"> \n'
          acl_tabelle = acl_tabelle + '</td> \n'
          acl_tabelle = acl_tabelle + '</tr> \n'
          acl_tabelle = acl_tabelle + '<tr> \n'
          if sprache == "de": acl_tabelle = acl_tabelle + '<td>Authentifizierte Benutzer</td> \n'
          else:               acl_tabelle = acl_tabelle + '<td>Authenticated Users</td> \n'
          acl_tabelle = acl_tabelle + '<td align="center"> \n'
          acl_tabelle = acl_tabelle + '<img src="bilder/'+AuthentUsersREAD+'" width="24" height="24" border="0" alt="'+AuthentUsersREAD+'"> \n'
          acl_tabelle = acl_tabelle + '</td> \n'
          acl_tabelle = acl_tabelle + '<td align="center"> \n'
          acl_tabelle = acl_tabelle + '<img src="bilder/'+AuthentUsersWRITE+'" width="24" height="24" border="0" alt="'+AuthentUsersWRITE+'"> \n'
          acl_tabelle = acl_tabelle + '</td> \n'
          acl_tabelle = acl_tabelle + '<td align="center"> \n'
          acl_tabelle = acl_tabelle + '<img src="bilder/'+AuthentUsersFULL+'" width="24" height="24" border="0" alt="'+AuthentUsersFULL+'"> \n'
          acl_tabelle = acl_tabelle + '</td> \n'
          acl_tabelle = acl_tabelle + '</tr> \n'
          acl_tabelle = acl_tabelle + '<tr> \n'
          if sprache == "de": acl_tabelle = acl_tabelle + '<td>'+OwnerName+' (Besitzer)</td> \n'
          else:               acl_tabelle = acl_tabelle + '<td>'+OwnerName+' Owner</td> \n'
          acl_tabelle = acl_tabelle + '<td align="center"> \n'
          acl_tabelle = acl_tabelle + '<img src="bilder/'+OwnerREAD+'" width="24" height="24" border="0" alt="'+OwnerREAD+'"> \n'
          acl_tabelle = acl_tabelle + '</td> \n'
          acl_tabelle = acl_tabelle + '<td align="center"> \n'
          acl_tabelle = acl_tabelle + '<img src="bilder/'+OwnerWRITE+'" width="24" height="24" border="0" alt="'+OwnerWRITE+'"> \n'
          acl_tabelle = acl_tabelle + '</td> \n'
          acl_tabelle = acl_tabelle + '<td align="center"> \n'
          acl_tabelle = acl_tabelle + '<img src="bilder/'+OwnerFull+'" width="24" height="24" border="0" alt="'+OwnerFull+'"> \n'
          acl_tabelle = acl_tabelle + '</td> \n'
          acl_tabelle = acl_tabelle + '</tr> \n'
          acl_tabelle = acl_tabelle + '</table> \n'

          # Wenn man sich NICHT unter Amazon befindet, funktioniert das Ändern der ACL nicht.
          if regionname == "Amazon":
            eucalyptus_warnung = ''
          elif regionname == "GoogleStorage":
            eucalyptus_warnung = ''
          else: 
            if sprache == "de":
              eucalyptus_warnung = '<B>Achtung!</B> Unter Eucalyptus 1.6 und 1.6.1 funktioniert das &Auml;ndern der Zugriffsberechtigung (Access Control List) nicht.</B>'
            else:
              eucalyptus_warnung = '<B>Attention!</B> With Eucalyptus 1.6 and 1.6.1 changing the ACL is broken.</B>'
            
          path = '&amp;path=s3&amp;mobile='+mobile
          
          template_values = {
          'navigations_bar': navigations_bar,
          'url': url,
          'url_linktext': url_linktext,
          'zone': regionname,
          'zone_amazon': zone_amazon,
          'zonen_liste': zonen_liste,
          'bucketname': bucketname,
          'keyname': keyname,
          'acl_tabelle': acl_tabelle,
          'typ': typ,
          'directory': directory,
          'eucalyptus_warnung': eucalyptus_warnung,
          'mobile': mobile,
          'path': path,
          }

          if mobile == "true":
              path = os.path.join(os.path.dirname(__file__), "../templates/mobile", sprache, "acl.html")
          else:
              path = os.path.join(os.path.dirname(__file__), "../templates", sprache, "acl.html")
          self.response.out.write(template.render(path,template_values))
    def post(self):
        mobile = self.request.get('mobile')
        if mobile != "true":
            mobile = "false"
        #self.response.out.write('posted!')
        # Die Eingabe aus dem Formular holen
        verzeichnisname = self.request.get('verzeichnisname')
        # Den Bucketnamen aus dem Formular holen
        bucketname = self.request.get('bucket')
        # Das Verzeichnis aus dem Formular holen
        directory = self.request.get('dir')

        # Den Usernamen erfahren
        username = users.get_current_user()

        if verzeichnisname == "":
            # Testen ob ein Name für den neuen key angegeben wurde
            # Wenn kein Name angegeben wurde, kann kein Key angelegt werden
            #fehlermeldung = "Sie haben keine Namen angegeben"
            fehlermeldung = "113"
            if directory == "/":
                self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                              '&bucket=' + bucketname + '&message=' +
                              fehlermeldung)
            else:
                # Den Slash am Ende des Verzeichnisses entfernen
                directory = str(directory[:-1])
                self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                              '&bucket=' + bucketname + '&message=' +
                              fehlermeldung + '&dir=' + directory)
        elif re.search(r'[^\-_a-zA-Z0-9]', verzeichnisname) != None:
            # Testen ob der Name für den neuen key nicht erlaubte Zeichen enthält
            fehlermeldung = "114"
            if directory == "/":
                self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                              '&bucket=' + bucketname + '&message=' +
                              fehlermeldung)
            else:
                # Den Slash am Ende des Verzeichnisses entfernen
                directory = str(directory[:-1])
                self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                              '&bucket=' + bucketname + '&message=' +
                              fehlermeldung + '&dir=' + directory)
        else:
            # Mit S3 verbinden
            conn_s3 = logins3(username)
            # Mit dem Bucket verbinden
            bucket_instance = conn_s3.get_bucket(bucketname)
            # Liste der Keys im Bucket
            liste_keys = bucket_instance.get_all_keys()
            # Anzahl der Keys in der Liste
            laenge_liste_keys = len(liste_keys)

            verzeichnisname = verzeichnisname + '_$folder$'

            # Variable erzeugen zum Erfassen, ob das neue Verzeichnis schon existiert
            schon_vorhanden = 0
            for i in range(laenge_liste_keys):
                # Key-Namen in einen String umwandeln
                vergleich = str(liste_keys[i].name)
                # Vergleichen
                if vergleich == verzeichnisname:
                    # Verzeichnis-Name existiert schon!
                    schon_vorhanden = 1
                    fehlermeldung = "117"
                    if directory == "/":
                        self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                                      '&bucket=' + bucketname + '&message=' +
                                      fehlermeldung)
                    else:
                        # Den Slash am Ende des Verzeichnisses entfernen
                        directory = str(directory[:-1])
                        self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                                      '&bucket=' + bucketname + '&message=' +
                                      fehlermeldung + '&dir=' + directory)

            # Wenn man noch kein Verzeichnis mit dem eingegebenen Namen besitzt...
            if schon_vorhanden == 0:
                try:
                    # Versuch das Verzeichnis anzulegen
                    # Mit dem Bucket sind wir schon verbunden über die Zeile
                    # bucket_instance = conn_s3.get_bucket(bucketname)
                    if directory == '/':
                        key = bucket_instance.new_key(verzeichnisname)
                        key.set_contents_from_string('')
                    else:
                        verzeichnisname = directory + verzeichnisname
                        key = bucket_instance.new_key(verzeichnisname)
                        key.set_contents_from_string('')
                except:
                    # Wenn es nicht klappt...
                    fehlermeldung = "116"
                    if directory == "/":
                        self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                                      '&bucket=' + bucketname + '&message=' +
                                      fehlermeldung)
                    else:
                        # Den Slash am Ende des Verzeichnisses entfernen
                        directory = str(directory[:-1])
                        self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                                      '&bucket=' + bucketname + '&message=' +
                                      fehlermeldung + '&dir=' + directory)
                else:
                    # Wenn es geklappt hat...
                    fehlermeldung = "115"
                    if directory == "/":
                        self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                                      '&bucket=' + bucketname + '&message=' +
                                      fehlermeldung)
                    else:
                        # Den Slash am Ende des Verzeichnisses entfernen
                        directory = str(directory[:-1])
                        self.redirect('/bucket_inhalt?mobile=' + str(mobile) +
                                      '&bucket=' + bucketname + '&message=' +
                                      fehlermeldung + '&dir=' + directory)