<s> import os <EOL> from django . core . management . base import BaseCommand <EOL> from django . core . serializers import serialize <EOL> from django . utils . translation import ugettext_lazy <EOL> from settings import ONADATA_DIR <EOL> from onadata . apps . logger . models import XForm , Instance <EOL> class Command ( BaseCommand ) : <EOL> help = ugettext_lazy ( "<STR_LIT>" ) <EOL> def handle ( self , * args , ** kwargs ) : <EOL> fixtures_dir = os . path . join ( ONADATA_DIR , "<STR_LIT>" ) <EOL> if not os . path . exists ( fixtures_dir ) : <EOL> os . mkdir ( fixtures_dir ) <EOL> xform_fp = os . path . join ( fixtures_dir , "<STR_LIT>" ) <EOL> instance_fp = os . path . join ( fixtures_dir , "<STR_LIT>" ) <EOL> xfp = open ( xform_fp , '<STR_LIT:w>' ) <EOL> xfp . write ( serialize ( "<STR_LIT>" , XForm . objects . all ( ) ) ) <EOL> xfp . close ( ) <EOL> ifp = open ( instance_fp , '<STR_LIT:w>' ) <EOL> ifp . write ( serialize ( "<STR_LIT>" , Instance . objects . all ( ) ) ) <EOL> ifp . close ( ) </s>
