Ejemplo n.º 1
0
 def test_fileio_support_with_chaining_and_all(self):
     f = phpserialize.BytesIO()
     phpserialize.dump([1, 2], f)
     phpserialize.dump(42, f)
     f = phpserialize.BytesIO(f.getvalue())
     self.assertEqual(phpserialize.load(f), {0: 1, 1: 2})
     self.assertEqual(phpserialize.load(f), 42)
Ejemplo n.º 2
0
 def test_fileio_support_with_chaining_and_all(self):
     f = phpserialize.BytesIO()
     phpserialize.dump([1, 2], f)
     phpserialize.dump(42, f)
     f = phpserialize.BytesIO(f.getvalue())
     self.assertEqual(phpserialize.load(f), {0: 1, 1: 2})
     self.assertEqual(phpserialize.load(f), 42)
Ejemplo n.º 3
0
def filter_meta_file(path):
    with open(path, 'rb') as f:
        data = phpserialize.load(f)

    for key in [b'current', b'persistent']:
        if key in data and b'last_change' in data[key] and isinstance(
                data[key][b'last_change'],
                dict) and b'ip' in data[key][b'last_change']:
            if data[key][b'last_change'][b'ip'] != b'127.0.0.1':
                data[key][b'last_change'][b'ip'] = b'redacted-ip'

    output = io.BytesIO()
    phpserialize.dump(data, output)
    size = output.tell()
    output.seek(0)

    return output, size
Ejemplo n.º 4
0
def main():
    db_password = raw_input("DB Password: "******"bundle" and artist = %s and album = %s'
                    cursor.execute(sql, (artist, album))
                    albumId = cursor.fetchone()['post_id']
                print('This album already exists - ' + album)

            songList = getSongList(artist, album)
            for song in songList:
                #				print ('Song Name: ' + song)
                if not any(item['item_type'] == 'single'
                           and item['artist'] == artist
                           and item['album'] == album and item['song'] == song
                           for item in checkList):
                    songId = uploadPost('single', artist, album, song, artwork,
                                        connection)
                    albumArray.append(songId)
                else:
                    with connection.cursor() as cursor:
                        sql = 'SELECT post_id from `upload_info` where item_type = "single" and artist = %s and album = %s and song = %s'
                        cursor.execute(sql, (artist, album, song))
                        songId = cursor.fetchone()['post_id']
                    albumArray.append(songId)
                    print('This song already exists - ' + song)

            phpserialize.dump(albumArray, albumSerialized)
            with connection.cursor() as cursor:
                sql1 = 'INSERT INTO `wp9r_postmeta` (`post_id`, `meta_key`, `meta_value`) VALUES (%s, "_edd_product_type", "bundle") ON DUPLICATE KEY UPDATE `meta_value` = "bundle"'
                sql2 = 'INSERT INTO `wp9r_postmeta` (`post_id`, `meta_key`, `meta_value`) VALUES (%s, "_edd_bundled_products", %s) ON DUPLICATE KEY UPDATE `meta_value` = %s'
                cursor.execute(sql1, (albumId))
                cursor.execute(sql2, (albumId, albumSerialized.getvalue(),
                                      albumSerialized.getvalue()))
        connection.commit()
    connection.close()