GAE: ValueError: Unsafe Ink Brine

I'm having trouble unpacking objects from the Google App Engine. I am running Windows 7. Here is the procedure:

  • Create a CSV with one of the fields pickle.dumps([[('CS', 2110), ('CS', 3300), ('CS', 3140)]])or a similar argument.

CSV looks something like this:

INFO,2210,"CS 2110, 3300, 3140","(lp0
(lp1
(S'CS'
p2
I2110
tp3
a(g2
I3300
tp4
a(g2
I3140
tp5
aa."

CS,3110,CS 2110 or equivalent experience,"(lp0
(lp1
(S'CS'
p2
I2110
tp3
aa."

MSE,4102,"MATH 2210, 2230, 2310, or 2940","(lp0
(lp1
(S'MATH'
p2
I2210
tp3
a(g2
I2230
tp4
a(g2
I2310
tp5
aa(lp6
(g2
I2940
tp7
aa."

(Yes it is \n, created pickle.dumps())

  1. Download this file in your devserver google device:

appcfg.py upload_data --config_file="DataLoader.py" --filename="pre_req_data.csv" --kind=Course --url=http://localhost:8083/remote_api "appdir"

Course Model :

class Course(db.Model):
    dept_code = db.StringProperty()
    number = db.IntegerProperty()
    raw_pre_reqs = db.StringProperty(multiline=True)
    original_description = db.StringProperty()

    def getPreReqs(self):
        pickle.loads(str(self.raw_pre_reqs))

DataLoader.py

class CourseLoader(bulkloader.Loader):
    def __init__(self):
        bulkloader.Loader.__init__(self, 'Course',
                                   [('dept_code', str),
                                    ('number', int),
                                    ('original_description', str),
                                    ('raw_pre_reqs', str)
                                   ])

loaders = [CourseLoader]
  1. Confirm that the data was downloaded successfully:

data storeindividual entity

  1. Try unpacking:

    MainHandler class (webapp.RequestHandler):

    def get(self):
        self.writeOut('cock!')
        self.writeOut('\n')
    
        courses = Course().all()
        for c in courses:
            self.writeOut("%s => %s" % (c.raw_pre_reqs, c.getPreReqs()))
    
    def writeOut(self, string):
        self.response.out.write(string)
    
  2. Watch the error:

    Traceback (last last call):

    File "C: \ Program Files \ Google \ google_appengine \ google \ appengine \ ext \ webapp__init __. Py", line 511, to call   handler.get (* group)

    "main.py", 30,   self.writeOut( "% s = > % s" % (c.raw_pre_reqs, c.getPreReqs()))

    "src\Models.py", 17, getPreReqs   pickle.loads( (self.raw_pre_reqs))

    "C:\Python26\lib\pickle.py" , 1374,   return Unpickler ().load()

    "C:\Python26\lib\pickle.py" , 858,   dispatchkey

    "C:\Python26\lib\pickle.py" , 966, load_string    ValueError, " "

    ValueError:

?

+3
2

Pickle - , CSV . - , base64.b64encode - .

+4

Pickle , ASCII ( 0). : pickle.dump.

, , CSV.

- , , , .

+2

Source: https://habr.com/ru/post/1748277/


All Articles