Exemple #1
0
def main():

    products = Product().GetList(items=400)["success"]

    d = DafitiModel()

    for p in products:

        category = GetCategories(p["category"])
        color = GetColor(p["color"])
        season = GetSeason(p["category"])

        if category:
            try:
                print "adding:", p["sku"]
                print p["category"], category
                print p["color"], color
                print season

                r = d.AddProduct(p["sku"], category.split(",")[0], category, color, season)

                if r.type == dafiti.Response.ERROR:
                    print "    error:", r.head
            except Exception, e:
                print "     ex: " + str(e)
            time.sleep(120)
Exemple #2
0
    def post(self, sku):

        categories = self.get_argument('categories', '')
        main_category = self.get_argument('main_category', '')
        color = self.get_argument('color', '')
        season = self.get_argument('season', '')

        if (categories == '' or main_category == '' or season == ''
                or color == ''):
            return

        d = DafitiModel()
        d.AddProduct(sku, main_category, categories, color, season)
Exemple #3
0
class DafitiTestCase(unittest.TestCase):

    def setUp(self):
        self.dafiti = DafitiModel()

    def test_add_sync_stock(self):

        self.dafiti.insertSync("foo", 10)
        self.assertEqual(self.dafiti.checkStock("foo"), 10)

        self.dafiti.insertSync("foo", 5)
        self.assertEqual(self.dafiti.checkStock("foo"), 5)

        self.assertEqual(self.dafiti.checkStock("nonexistent"), 0)
Exemple #4
0
if "enviroment" not in options:

    print enviroment

    define("enviroment", default=enviroment, type=str)
    define("db_name", default=DB_NAME, help="", type=str)
    define("db_user", default=DB_USER, help="", type=str)
    define("db_host", default=DB_HOST, help="", type=str)
    define("db_password", default=DB_PASSWORD, help="", type=str)

# -------------------

if __name__ == "__main__":

    model = DafitiModel()
    client = dafiti.API(user_id='*****@*****.**',
                        api_key='aa8051656b6b1efab5b52615e2e4e2fe913b13d7',
                        response_format='json',
                        environment=dafiti.Environment.Live)

    response = client.product.Get(Filter=dafiti.Filter.All)

    counter_a = 0
    counter_b = 0

    requests = []
    product_request = []

    for p in response.body["Products"]["Product"]:
        name_fixed = model.nameFix(p["Name"])
Exemple #5
0
def job():
    dafiti = DafitiModel()
    dafiti.syncronizeStock()
Exemple #6
0
 def setUp(self):
     self.dafiti = DafitiModel()
Exemple #7
0
 def get(self):
     d = DafitiModel()
     self.write(
         d.GetCategories()["Categories"]["Category"][0]["Children"] \
         ["Category"][0]["Children"])
Exemple #8
0
 def get(self, sku):
     d = DafitiModel()
     d.RemoveProduct(sku)
Exemple #9
0
    def get(self, sku):

        d = DafitiModel()

        self.write({"synchronized": d.ProductExist(sku)})