EzDevInfo.com

epf

A framework for keeping your Ember.js apps in sync. EPF: Ember.js Persistence Foundation

Importing EPF file could not complete because got incorrect string value error

I have installed mysql 5.5 and mysqldb for python [MySQL-python-1.2.3.win32-py2.7], python version 2.7

also, create new database with charset utf8 and installed from apple itunes.rar and extract it.

then open cmd and go to python directory then type: EPFImporter.py itunes

itunes: folder contains application EPF

when run it i got the following error:

2014-09-02 14:49:33,706 [INFO]: Beginning import for the following directories:
    it
2014-09-02 14:49:33,707 [INFO]: Importing files in it
2014-09-02 14:49:33,709 [INFO]: Starting import of C:\Python27\app\it...
2014-09-02 14:49:33,710 [INFO]: Beginning full ingest of app00511_application (1315569 records)
2014-09-02 14:49:34,698 [ERROR]: Fatal error encountered while ingesting 'C:\Python27\app\it\application'
Traceback (most recent call last):
  File "C:\Python27\app\EPFIngester.py", line 129, in ingestFull
    self._populateTable(self.tmpTableName, skipKeyViolators=skipKeyViolators)
  File "C:\Python27\app\EPFIngester.py", line 380, in _populateTable
    cur.execute(exStr)
  File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 202, in execute
    self.errorhandler(self, exc, value)
  File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
OperationalError: (1366, "Incorrect string value: '\\xF0\\x9F\\x91\\x8D \\xE8...' for column 'description' at row 47")
2014-09-02 14:49:34,700 [ERROR]: Last record ingested before failure: 1200
2014-09-02 14:49:34,703 [INFO]: Import of it completed at: 14-09-02 14:49:34
2014-09-02 14:49:34,703 [INFO]: Total import time for it: 0:00:00.99
2014-09-02 14:49:34,703 [WARNING]: The following files encountered errors and were not imported:
 application
2014-09-02 14:49:34,706 [WARNING]: The following files encountered errors and were not imported:
        it/['application']
2014-09-02 14:49:34,706 [INFO]: Total import time for all directories: 0:0

I read in some articles that said we should use utf8mb4 instead but when change charset for connection in EPFIngester.py file to utf8mb4 like the follwoing:

conn = MySQLdb.connect(
        charset='utf8mb4', 
        host=self.dbHost, 
        user=self.dbUser, 
        passwd=self.dbPassword, 
        db=self.dbName)
        return conn

i got this error:

C:\Python27\app>EPFImporter.py it
2014-09-02 14:58:33,742 [INFO]: Beginning import for the following directories:
    it
2014-09-02 14:58:33,743 [INFO]: Importing files in it
2014-09-02 14:58:33,744 [INFO]: Starting import of C:\Python27\app\it...
2014-09-02 14:58:33,746 [INFO]: Beginning full ingest of app00511_application (1
315569 records)
2014-09-02 14:58:33,769 [ERROR]: Fatal error encountered while ingesting 'C:\Pyt
hon27\app\it\application'
Traceback (most recent call last):
  File "C:\Python27\app\EPFIngester.py", line 128, in ingestFull
    self._createTable(self.tmpTableName)
  File "C:\Python27\app\EPFIngester.py", line 297, in _createTable
    conn = self.connect()
  File "C:\Python27\app\EPFIngester.py", line 240, in connect
    db=self.dbName)
  File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 215, in __in
it__
    self.set_character_set(charset)
  File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 298, in set_
character_set
    super(Connection, self).set_character_set(charset)
OperationalError: (2019, "Can't initialize character set utf8mb4 (path: C:\\mysq
l\\\\share\\charsets\\)")
2014-09-02 14:58:33,772 [ERROR]: Last record ingested before failure: -1
2014-09-02 14:58:33,773 [INFO]: Import of it completed at: 14-09-02 14:58:33
2014-09-02 14:58:33,775 [INFO]: Total import time for it: 0:00:00.02
2014-09-02 14:58:33,775 [WARNING]: The following files encountered errors and we
re not imported:
 application
2014-09-02 14:58:33,775 [WARNING]: The following files encountered errors and we
re not imported:
        it/['application']
2014-09-02 14:58:33,776 [INFO]: Total import time for all directories: 0:00:00.0
3

I am searching to solve this issue but no luck. could anyone face like this issue and has the solution.

Note: all operations above on Windows.


Source: (StackOverflow)

HttpWebResponse cutting off early when downloading large file

I am using a C# Client class provided by the USPS EPF (Electronic Product Fulfillment) in order to download USPS files through a console application. I use my console app to login with my USPS credentials, specify the file I want to download, and get the file. All of this works great for the two smaller files we have access to (AMS Developer Kit, 47.7 MB, and DPV Developer Kit, 1.59 MB). However, when I try to download the 2.8 GB AMS Commercial DVD file, which is the only one I really care about, I run into problems. The console app stops downloading the file at 1.75 GB every time. Since it's a .tar file, I can open it and see some of the contents, but naturally a lot is missing. The USPS-provided Client class does not throw an exception or error of any kind; it's supposed to read to the end of the file, but it just stops early.

I have tried everything I can think of: altering the HttpWebRequest properties (changing KeepAlive to true, increasing the Timeout value), modifying the getEpfFile method to use an IsolatedStorageFile instead of a MemoryStream to get the file, even checking with our networking people to make sure there isn't some arbitrary network setting causing a timeout. I've tried downloading from my machine and different network servers with the same result. I looked into using WebClient instead, but that requires a parameter of the entire URL of the file to download, which is not known. I have to use HttpWebRequest, as far as I can tell, to access the USPS EPF files at all.

This is the getEpfFile method from the Client.cs class provided by USPS (I apologize for any formatting issues, this is my first post on the site):

// get actual file

    public bool getEpfFile(String fileid)
    {
        bool downloadSuccess = true;
        string strUrl = this.strBaseUrl + "/download/epf";

        try
        {

            Console.WriteLine("Starting file download ...");

            // add json to URL
            Dictionary<string, string> json_value = new Dictionary<string, string>();
            json_value.Add("logonkey", this.logon_key);
            json_value.Add("tokenkey", this.token_key);
            json_value.Add("fileid", fileid);

            JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
            string json_string = "obj=" + jsonSerializer.Serialize(json_value);

            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            Byte[] byteArray = encoding.GetBytes(json_string);

            // set URL              
            Uri address = new Uri(strUrl);

            // web request  
            HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;

            request.UserAgent = "USPS .NET Sample";
            request.KeepAlive = false;
            request.Timeout = 100000;

            request.ProtocolVersion = HttpVersion.Version10;

            request.Method = "POST";
            request.ContentLength = byteArray.Length;
            request.ContentType = "application/x-www-form-urlencoded";

            // add headers
            // request.Headers.Add("Akamai-File-Request", filepath);
            request.Headers.Add("logonkey", this.logon_key);
            request.Headers.Add("tokenkey", this.token_key);
            request.Headers.Add("fileid", fileid);

            // post request
            Stream dataStream = request.GetRequestStream();
            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();

            // Get response  
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;


            if (request.HaveResponse == true && response != null)
            {

                Stream remoteStream = response.GetResponseStream();

                Directory.CreateDirectory("c:\\Atemp");
                Stream localStream = File.Create("c:\\Atemp\\dd.tar");

                //byte[] buffer = new byte[2048];
                byte[] buffer = new byte[1000000];

                int bytesRead = 0;

                do
                {
                    // Read data (up to 1k) from the stream
                    bytesRead = remoteStream.Read(buffer, 0, buffer.Length);

                    // Write the data to the local file
                    localStream.Write(buffer, 0, bytesRead);

                } while (bytesRead > 0);


                int i = response.Headers.Count;


                for (int x = 0; x < i; x++)
                {

                    if (response.Headers.Keys[x].ToString() == "User-Tokenkey")
                    {
                        this.token_key = response.Headers[x].ToString();
                    }
                    else if (response.Headers.Keys[x].ToString() == "User-Logonkey")
                    {
                        this.logon_key = response.Headers[x].ToString();
                    }

                    else if (response.Headers.Keys[x].ToString() == "Service-Response")
                    {
                        Console.WriteLine("Web service result: " + response.Headers[x].ToString());
                    }
                    else if (response.Headers.Keys[x].ToString() == "Service-Messages")
                    {
                        Console.WriteLine("Resulting Messages: " + response.Headers[x].ToString());
                    }

                }

                // close resources
                localStream.Close();
                remoteStream.Close();
                response.Close();

                Console.WriteLine("File Download completed.");
            }
        }
        catch (Exception ex)
        {
            downloadSuccess = false;
            string str = ex.Message;
            str += "";
        }

        return downloadSuccess;
    }

Any insight as to why it keeps cutting off early would be massively appreciated.


Source: (StackOverflow)

Advertisements

Import of large itunes epf database is not working

I'm trying to import EPF relational database. Itunes epf relational database is consist of details of all database ( application,music,tv shows,games etc). You can find more on this here Itunes EPF Relation Database I can be able to import all database except one database which is not processing. This file is around 6gb.

$field_separator = chr(1);
                                $record_separator = chr(2)."\n";   
                                $data_appdt=explode($record_separator,file_get_contents('file_path',true));
                                    foreach ($data_appdt as $key => $value) 
                                    {
                                    if (substr($value, 0, 1) != '#')
                                        {
                                            if (!empty($value))
                                            {
                                            {
                                                $data_itu_app_dt=explode($field_separator, $value);
                                                $result=$this->admin_model->itunes_app_dt($data_itu_app_dt);
                                            }
                                            }
                                        }
                                    }

The above code is done in codeigniter which is the controller for the import process.This code works for around upto 2gb file. But for size larger than that its not working. Maybe its reading the whole file and memory doesn't allow it to do so. So i used the below code for processing higher files.

    $handle = fopen('file_path', "r") or die("Couldn't get handle");
                            if ($handle) {
                            while (!feof($handle)) {
                            $buffer = fgets($handle, 4096);
                            $data_appp=explode($record_separator,$buffer);
                            foreach ($data_appp as $key => $value) 
                            {
                            if (substr($value, 0, 1) != '#')
                            {
                                if (!empty($value))
                                {
                                    $data_itu_appp=explode($field_separator, $value);
                                    //print_r($data_itu_appp);
                                    $result=$this->admin_model->itunes_appp($data_itu_appp);
                                }
                            }   
                            }
                                }
                            fclose($handle);
                                }

It works for even 8gb files and the import is done and completed successfully. But then for a 6gb file the import is not going on. This is the sample data for the table

1426669253786|329704232|EN|iParrot Phrase Vietnamese-Italian|Translate Vietnamese Phrase to Italian Taking-with Translator for iPad/iPhone/iPod Touch|

iParrot Phrase sets a new standard for instant multi-language translation software. Designed exclusively for the iPad/iPhone/iPod Touch, it’s stocked with over 20 kinds of perfectly pronounced oral language for instant use. iParrot Phrase is organized into categories such as: Greetings, Transportation, Shopping, and Asking for helping etc. So it is enough for you to find the sentences you need instantly. Organized for instant access and ease, it is especially useful while traveling abroad. Virtual fluency available in Chinese, English, Japanese, Russian, French, German, Spanish, Italian, Korean, Portuguese, Arabic, Thai and Vietnamese.

This is the sample data from that database which is application detail ( In above the sample data that i replaced ASCII characters (SOH) for new field with |). Actually when the import is in process using the second code when the new line comes its taking it as /n and the import getting broken. So is there any ways to get around this or any other method to process such large file (6 GB) for database import ? Maybe the above things are little confusing. Is there any clarification needed then i will make things more clear. Looking for a good solution.. Thanks all.


Source: (StackOverflow)

What is the state of offline-syncing in ember at the moment?

I need to build a phonegap/cordova app which keeps a local copy of models which can be amended and then be synced remotely to the server?

So far I've found:

  • ember-data-sync: dead
  • ember-data: doesn't support sync
  • epf: looks like the best shot, but not hugely active and doesn't seem to have been updated past 1.0.0.rc6

What's the best way for me to achieve this, and what software stack, with versions do I need to use in order to do so?

Or would it be advisable for me to use a different js framework for me to achieve this?

Thanks in advance.


Source: (StackOverflow)

Eclipse: import Java compiler preferences only for project

I have altered the Java compiler settings in my workspace, exported these settings as epf file and resetted the compiler settings workspace wide back to its default. Because I want these settings only in 2 projects in my workspace.

Now, how can I achieve this, importing the epf file for only one project? I am aware of the „enable project specific settings“ option and enabled it and right clicked on the project, imported the epf file but nothing happened. Neither did it change the compiler settings for the project nor for the whole workspace.

If I import it via file menu it works for the whole workspace. I want to share it with a colleague and not go through each option step by step (there are just too many) and using these settings for the whole workspace is insufficient because it then generates about 2000 errors.

I guess it is possible since it has an extra import settings option when right clicking on a project.


Source: (StackOverflow)

Ember.js "isDirty" not being cleared on save with both Epf and Ember-Data (1.0.0.beta.2)

I'm having a problem using Ember. When I change a model, its "isDirty" flag becomes true, which is what I expect.

However, after that its "isDirty" flag is true, even after I save that model.

Here's a minimal Rails + Ember project (so I can actually save the model) that shows the situation:

https://github.com/csterritt/etst

Am I doing something wrong? Is this expected behavior?

Thanks!


Edit: Turns out that, as Jeremy Green pointed out below, the "isDirty" flag works for Ember Data.

And, it works with the current Ember 1.0.0 (standard, not -latest) and Ember Data beta.

I was doing:

  isClean: ( ->
    ! @get("isDirty")
  ).property("name", "age", "favorite_food")

Which was due to a misunderstanding on my part. Changing this to:

  isClean: ( ->
    ! @get("isDirty")
  ).property("isDirty")

Works properly.

Unfortunately, this doesn't solve the Epf version's problem. Epf-ites?


Source: (StackOverflow)

Validation failures with EPF-backed Ember models

I'm working on a project using EPF and having trouble when dealing with resources which fail with validation errors on the server.

I am creating a new user registration page, which takes an email address, login and password and asks the server to create a new user record via the REST API.

When validation fails the server returns a 422 with an errors hash in the JSON response.

First, I tried using the session.flush promise to get access to the response body:

registerNewUser: ->
  onSuccess = (models)=>
    newUser = @get('content')
    @transitionToRoute('user', newUser)
  onFailure = (response)->
    debugger
  @session.flush().then(onSuccess, onFailure)

The response argument passed to the decline action actually contains an Exception (in my case: "TypeError: Cannot call method 'toString' of undefined". Investigating the stack shows that it is an exception from deep within EPF - I'm pretty sure this is a bug, but I need to do more digging to confirm this.

"Okay," I thought. "I'll read the EPF source".

I came across https://github.com/GroupTalent/epf/blob/master/lib/rest/rest_adapter.js#L267 which appears to fire when the jQuery AJAX promise declines. It has a specific test for 422 and attempts to parse the JSON payload and attach it (along with a bunch of other useful information) to the model on the errors property. However, my newly-created user model has no errors property either.

Pretty much at a dead end for now. Does anyone know where I should be looking to make this work?


Source: (StackOverflow)

How do I include epf.js in a project using ember-tools?

I'm integrating an ember project to use ember-tools because I want nice build tools. My project also uses epf, and I encountered a problem when I tried to include epf.js as a library. My instinct was just to lump epf.js into the vendor/ folder that ember-tools had generated for me... but this doesn't work. When I run ember build it spits out the following:

Change detected: !config/app.js

   created: js/templates.js
   created: js/index.js
   created: js/application.js
build time: 493 ms
 Error: Cannot find module '/lib/version.js'

I think this is happening because epf.js uses commonjs syntax, as in

 require.define('/lib/index.js', function (module, exports, __dirname, __filename) {
        global.Ep = Ember.Namespace.create();
        require('/lib/version.js', module);

and ember-tools' build command thinks these require statements are declaring modules that it should build.

Is this a problem in general when using commonjs syntax? Is there some easy fix that will allow me to use ember-tools' build command to include epf.js, or should I keep a separate lib folder somewhere and just put a <script> tag in index.html?

EDIT

epf.js begins,

(function(global) {

and exports the Ep object as

global.Ep = Ember.Namespace.create();

This was causing problems, so I added global = window; and var Ember = window.Em. Later in the file there is a function called require which I renamed to requireEPF.

These terrible hacks have got me started, but I'd like to know if there is a better way.


Source: (StackOverflow)

Apply settings from edited eclipse epf file

we exported eclipse settings in an epf file. Afterwards we change the encoding setting and exported another epf file. The diff shows us only one setting:

/instance/org.eclipse.core.resources/encoding=UTF-8

When we try to import this setting into eclipse the encoding doesn't change and in the import dialog there is an error message shown:

Empty list.

Note: Not all preferences support individual import.

Does anybody know how to find out which preferences belongs together?

We need to have stripped down epf files, because we only want to change specific settings.

regards Andreas


Source: (StackOverflow)