def __timer_thread(self) : # port_check = time.time() while not self.__get_should_finish() : tm = time.time() jobs = [] try : while not self.__jobs.empty() : jobs.append(self.__jobs.get_nowait()) except QueueEmpty : pass # print here(), jobs for job_type, job_args in jobs : if job_type == "build" : print(here()) board_type, sheets, meta = job_args self.build_job(board_type, sheets, meta)#TODO try..except if job_type == "upload" : print(here()) self.upload_job(*job_args) #TODO put to message to signal job done if time.time() - tm < 0.3 : time.sleep(0.3) #TODO TODO TODO self.__timer_job() now = time.time()
def parse_vmex_export(export, known_types) : # print here(), export ret_type, name, args_list = export assert(VMEX_SIG in ret_type) # print here(), name args_info = [] for arg_group, i in zip(__group_vmex_args(args_list), count()) : # print here(), len(arg_group) arg_group_len = len(arg_group) if arg_group_len == 1 : a = vmex_arg(arg_group[0], known_types, i) args_info.append(a) elif arg_group_len == 2 : (cnt_sig, cnt_name), (lst_sig, lst_name) = arg_group # print here(), cnt_name, cnt_sig, lst_name, lst_sig if "_VM_VA_CNT_" and cnt_sig and "_VM_VA_LST_" in lst_sig and "*" in lst_sig : if "_VM_INPUT_" in cnt_sig : direction = INPUT_TERM elif "_VM_OUTPUT_" in cnt_sig : direction = OUTPUT_TERM else : raise Exception(here() + " variadic term declaration lacks direction") a = vmex_arg((lst_sig, lst_name), known_types, i, variadic=True, direction=direction) args_info.append(a) else : raise Exception(here() + " invalid variadic term declaration") else : raise Exception(here() + " argument grouping error") # for sig, arg_name in arg_group : # print here(), arg_name # return name, term_type, direction, variadic, commutative # print here() # pprint(args_info) vmex_ret_type = None for tp in ret_type : if tp in known_types : vmex_ret_type = tp terms_in = [ a for a in args_info if a.direction == INPUT_TERM ] terms_out = [ a for a in args_info if a.direction == OUTPUT_TERM ] if not terms_out and not "void" in ret_type : terms_out = [ vmex_arg((ret_type, "out"), known_types, len(terms_in)) ] # print here(), [ai.name for ai in terms_in], [ai.name for ai in terms_out] return name, (terms_in, terms_out)
def create(dest): if isinstance(dest, basestring): dest = fs.Directory(dest) # create or clear destination if dest.exists: dest.remove(recursive=True) dest.create() # copy over assets assets = fs.Directory(utils.here('../build/resources')) assets.copy(dest, root=True) vendor = fs.Directory(utils.here('../vendor')) vendor.copy(fs.Directory(dest.path, 'resources'), root=True)
def get_workbench_dependencies(fname) : """ return set of block types immediately needed by workbench file fname these block types may have other dependencies """ try : with open(fname, "rb") as f : version, meta, resources = serializer.unpickle_workbench_data(f) except Exception as e : print(here(), "error loading workbench file", fname, e) return None used_types = set() #XXX type_names must be unique -> need to extend them with library path, including c modules for r_type, r_version, r_name, resrc in resources : if (r_type == serializer.RES_TYPE_SHEET and r_version == serializer.RES_TYPE_SHEET_VERSION and is_macro_name(r_name) ) : types, struct, meta = resrc for nr, block_type in types : lib_name, type_name = split_full_type_name(block_type) if lib_name : used_types.update((block_type,)) return used_types
def load_library(lib, library=None) : """ return blocks loaded from library described by lib_info_t instance lib """ lib_items = [] include_files = [] source_files = [] for file_info in sorted(lib.files) : blocks = [] if file_info.file_type == "c" : if __is_header(file_info.path) : include_files.append(file_info.path) blocks = load_c_library(lib.lib_name, file_info.path) else : source_files.append(file_info.path)#XXX is this filter sufficient # print here(), file_info.path elif file_info.file_type == "w" : blocks = load_workbench_library(lib.lib_name, file_info.path, library=library) else : raise Exception(here(), "unknown lib file type '" + file_info.file_type + "'") items = [ (be_lib_block_t(lib.lib_name, file_info.path, file_info.file_type, b.type_name, b.type_name), b) for b in blocks ] lib_items.extend(items) return be_library_t( name=lib.lib_name, path=lib.path, allowed_targets=None,#TODO include_files=tuple(include_files),#f.path for f in lib.files), source_files=tuple(source_files), items=lib_items)
def sort_libs(libs) : """ from list of lib_info_t generate list of lib names topologicaly sorted by their dependencies """ g = {} s = [] for lib in libs : deps = set() for file_info in lib.files : for full_type in file_info.using_types : lib_name, type_name = split_full_type_name(full_type) deps.add(lib_name) if deps : g[lib.lib_name] = deps else : s.append(lib.lib_name) reached = set(s) while g : removed = [] for k, v in g.items() : if v.issubset(reached) : s.append(k) removed.append(k) reached.add(k) if g and not removed : print(here() + " probable cyclic dependency") return None for k in removed : g.pop(k) return s
def load_library(self, lib_basedir) : basedir = os.path.abspath(lib_basedir) dir_walk = tuple(islice(os.walk(basedir), 1)) if not dir_walk : return None (_, dirnames, _), = dir_walk libs = {} for d in dirnames : path = os.path.abspath(os.path.join(basedir, d)) lib = scan_library(basedir, path) libs[lib.lib_name] = lib sorted_libs = sort_libs(libs.values()) for l in sorted_libs : loaded = load_library(libs[l]) self.libs.append(loaded) for item, proto in loaded.items : ok, errors = prototype_sanity_check(proto) if ok : self.__blocks.append(proto) else : print(here(), "skipped proto", proto, "because", errors) return (True, )
def test_fixture_patch(patch_fixture): dump_config(config) path = os.path.join(HERE, '.conf.json') assert path == patch_fixture # 这时候fixture的patch仍然有效 assert path != here(__name__) + os.path.sep + '.conf.json' expected = json.load(open(path, 'r', encoding='utf-8')) assert expected == config
def wrap(*a, **b) : try : ret = f(*a, **b) except Exception as e : print(here(10), e) os._exit(1) else : return ret
def read_messages(self) : messages = [] try : while not self.__messages.empty() : messages.append(self.__messages.get_nowait()) print(here(), messages[-1]) except QueueEmpty : pass return messages
def test_patch_config(tmpdir, monkeypatch): fake_path = tmpdir.mkdir('home') monkeypatch.setattr(os.path, 'join', lambda *args: str(fake_path.join('.conf.json'))) dump_config(config) path = os.path.join(HERE, '.conf.json') # 这时候已经被monkeypatch了 assert path != here(__name__) + os.path.sep + '.conf.json' expected = json.load(open(path, 'r', encoding='utf-8')) assert expected == config
def load_standalone_workbench_lib(self, path, lib_name, library=None, w_data=None) : loaded = load_standalone_workbench_lib(path, lib_name, library=library, w_data=w_data) self.libs.append(loaded) for item, proto in loaded.items : ok, errors = prototype_sanity_check(proto) if ok : self.__blocks.append(proto) else : print(here(), "skipped proto", proto, "because", errors) return (True, )
def main(port, baudrate, parity): ser = serial.Serial() ser.port = port ser.baudrate = baudrate ser.parity = parity ser.open() frame = [] while True: c = ser.read() #TODO use timeout to handle frame spacing if "0" <= c <= "9" or "A" <= c <= "F" or c == "\r": frame.append(c) elif c == ":": frame = [] elif c == "\n": decode(frame) frame = [] else: frame = [] print here(), "invalid char ", ord(c), "dec received"
def main(port, baudrate, parity) : ser = serial.Serial() ser.port = port ser.baudrate = baudrate ser.parity = parity ser.open() frame = [] while True : c = ser.read()#TODO use timeout to handle frame spacing if "0" <= c <= "9" or "A" <= c <= "F" or c == "\r" : frame.append(c) elif c == ":" : frame = [] elif c == "\n" : decode(frame) frame = [] else : frame = [] print here(), "invalid char ", ord(c), "dec received"
def build(self) : try : board_type = self.get_board() sheets = self.sheets meta = self.get_meta() #XXX XXX XXX clone data before passing to job queue!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! self.__jobs.put(("build", (board_type, sheets, meta))) # self.build_job(board_type, sheets, meta)#TODO refac build invocation except Exception as e : print(here(), traceback.format_exc()) self.__messages.put(("status", (("build", False, "compilation_failed"), {}))) #TODO say why
def start_streaming(request, mix_id): logger.debug('Start streaming called: %s' % mix_id) try: mix = Mix.objects.get(pk=mix_id) if mix is not None: mix.add_play(request.user) # logger.debug('Found the mix (old method): %s' % mix.uid) logger.debug('Found the mix (new method) %s' % mix.uid) filename = "%s/mixes/%s.mp3" % (here(settings.MEDIA_ROOT), mix.uid) logger.debug('Serving file: %s' % filename) response = sendfile(request, filename) return response except Exception, ex: print ex
def make_dag(model, meta, known_types, do_join_taps=True, delay_numbering_start=0) : conns0 = { k : v for k, v in model.connections.items() if v } model_blocks = tuple(b for b in model.blocks if not core.compare_proto_to_type(b.prototype, core.TextAreaProto)) blocks, conns1, delays = __expand_delays(model_blocks, conns0, delay_numbering_start) conns_rev = reverse_dict_of_lists(conns1, lambda values: list(set(values))) graph = { b : adjs_t( [ (t, n, conns_rev[(b, t, n)] if (b, t, n) in conns_rev else []) for t, n in in_terms(b) ], [ (t, n, conns1[(b, t, n)] if (b, t, n) in conns1 else []) for t, n in out_terms(b) ]) for b in blocks } is_sane = __dag_sanity_check(graph, stop_on_first=False) if not is_sane : raise Exception(here() + ": produced graph is insane") __expand_joints_new(graph) if do_join_taps : join_taps(graph) return graph, delays
def decode(buf) : assert(len(buf) >= 10) assert(buf[-1] == "\r") assert(not ((len(buf)-1) % 2)) frame = "".join(chr((int(h, 16) << 4) + int(l, 16)) for h, l in zip(buf[0:-1:2], buf[1:-1:2])) if sum(ord(c) for c in frame) % 2 : print here(), "invalid lrc" return None addr, function = struct.unpack(">BB", frame[:2]) if function == 0x10 : register, reg_cnt, byte_cnt = struct.unpack(">HHB", frame[2:7]) assert(byte_cnt == 2 * reg_cnt) reg_values = struct.unpack(">" + reg_cnt * "H", frame[7:-1]) print here(), addr, function, register, reg_cnt, byte_cnt, reg_values return addr, function, (register, reg_cnt, byte_cnt, reg_values) else : print here(), "unsupported function" return None
def decode(buf): assert (len(buf) >= 10) assert (buf[-1] == "\r") assert (not ((len(buf) - 1) % 2)) frame = "".join( chr((int(h, 16) << 4) + int(l, 16)) for h, l in zip(buf[0:-1:2], buf[1:-1:2])) if sum(ord(c) for c in frame) % 2: print here(), "invalid lrc" return None addr, function = struct.unpack(">BB", frame[:2]) if function == 0x10: register, reg_cnt, byte_cnt = struct.unpack(">HHB", frame[2:7]) assert (byte_cnt == 2 * reg_cnt) reg_values = struct.unpack(">" + reg_cnt * "H", frame[7:-1]) print here(), addr, function, register, reg_cnt, byte_cnt, reg_values return addr, function, (register, reg_cnt, byte_cnt, reg_values) else: print here(), "unsupported function" return None
def test_after(): """All modifications will be undone after the requesting test function or fixture has finished.""" path = os.path.join(HERE, '.conf.json') assert path == here(__name__) + os.path.sep + '.conf.json'
SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale. USE_L10N = True # If you set this to False, Django will not use timezone-aware datetimes. USE_TZ = False # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = here('media') # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = '' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = here('static') # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/'
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'kankim' , # Or path to database file if using sqlite3. 'USER': '', # Not used with sqlite3. 'PASSWORD': '', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. } } TIME_ZONE = 'America/Chicago' LANGUAGE_CODE = 'Tr-tr' SITE_ID = 1 MEDIA_ROOT = here('static') MEDIA_URL = 'static' ADMIN_MEDIA_PREFIX = '/static/admin/' SECRET_KEY = 'c3i3%yr%1!#7gwhr4#7lr=&m$$i8d=gq8+nn=t^rjd!p0_f^)k' TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', ) TEMPLATE_CONTEXT_PROCESSORS = ( "django.contrib.auth.context_processors.auth", "django.core.context_processors.debug",
import json import os import pytest from utils import here HERE = here(__name__) config = {"1": "123", "2": "456", "3": 345, '9': [2, 34]} def dump_config(config): path = os.path.join(HERE, '.conf.json') with open(path, 'w', encoding='utf-8') as wr: json.dump(config, wr, indent=4) @pytest.mark.skip(reason="不应该修改真实环境的数据") def test_config(): dump_config(config) path = os.path.join(HERE, '.conf.json') expected = json.load(open(path, 'r', encoding='utf-8')) assert expected == config @pytest.mark.run(order=3) def test_after(): """All modifications will be undone after the requesting test function or fixture has finished.""" path = os.path.join(HERE, '.conf.json')
# http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'TR-tr' SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale USE_L10N = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = here('static') # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = '/static/media/' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = "" # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/'
# http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'TR-tr' SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale USE_L10N = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = here('static') # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = '/static/' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = "" # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = 'http://ismailabi.com/static/'
import jinja2 import utils import parser loader = jinja2.FileSystemLoader(utils.here('templates')) environment = jinja2.Environment(loader=loader) def content(blocks): template = environment.get_template('content.html') return template.render(blocks=blocks) def document(title, blocks, **options): template = environment.get_template('document.html') return template.render(title=title, blocks=blocks, options=options) def pipe(): raise NotImplementedError() # REFACTOR: old code, but I want to offer similar functionality # to provide a very easy way to allow for custom templating def replace(src, body): assets = None if os.path.isfile(src): template = open(src).read() else: template = open(os.path.join(src, 'template.html')).read()
import jinja2 import utils import parser loader = jinja2.FileSystemLoader(utils.here('templates')) environment = jinja2.Environment(loader=loader) def content(blocks): template = environment.get_template('content.html') return template.render(blocks=blocks) def document(title, blocks, **options): template = environment.get_template('document.html') return template.render(title=title, blocks=blocks, options=options) def pipe(): raise NotImplementedError() # REFACTOR: old code, but I want to offer similar functionality # to provide a very easy way to allow for custom templating def replace(src, body): assets = None if os.path.isfile(src): template = open(src).read() else: template = open(os.path.join(src, 'template.html')).read() assets_dir = os.path.join(src, 'assets') if os.path.exists(assets_dir): assets = assets_dir
# Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = '' STATIC_URL = '/static/' # URL prefix for admin static files -- CSS, JavaScript and images. # Make sure to use a trailing slash. # Examples: "http://foo.com/static/admin/", "/static/admin/". ADMIN_MEDIA_PREFIX = '/static/admin/' # Additional locations of static files STATICFILES_DIRS = ( here('static'), # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ) # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', #'django.contrib.staticfiles.finders.DefaultStorageFinder', ) # Make this unique, and don't share it with anybody. SECRET_KEY = 'fk_lki_r5cutf=kn+bo(ku8nr!tpc4#&g*q%ms21v_ep!lqakw'
('en', 'English'), ) SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale USE_L10N = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = here('uploads/') # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = '/uploads/' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = here('static/') # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/'
} } import sys if 'test' in sys.argv or 'test_coverage' in sys.argv: print "Testing" DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3' ROOT_URLCONF = 'dss.urls' TIME_ZONE = 'Europe/Dublin' LANGUAGE_CODE = 'en-ie' SITE_ID = 1 USE_I18N = False USE_L10N = True s = True SITE_ROOT = here('') ADMIN_MEDIA_PREFIX = STATIC_URL + "grappelli/" STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'compressor.finders.CompressorFinder', 'pipeline.finders.PipelineFinder', 'pipeline.finders.CachedFileFinder', ) STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' STATICFILES_DIRS = ( here('static'), )
def sethi_ullman(g) : #TODO testing, is it (easily) possible to algorithmically create graph with given numbering? print(here()) numbering = {} dft_alt(g, post_visit = partial(__su_post_visit, g, numbering)) return numbering
} } import sys if 'test' in sys.argv or 'test_coverage' in sys.argv: DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3' ROOT_URLCONF = 'dss.urls' TIME_ZONE = 'Europe/Dublin' LANGUAGE_CODE = 'en-ie' SITE_ID = 1 USE_I18N = False USE_L10N = True s = True SITE_ROOT = here('') ADMIN_MEDIA_PREFIX = STATIC_URL + "grappelli/" STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'compressor.finders.CompressorFinder', 'pipeline.finders.PipelineFinder', ) STATICFILES_DIRS = (here('static'), ) # STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' STATICFILES_STORAGE = 'django_pipeline_forgiving.storages.PipelineForgivingStorage'
def main() : started = time.time() files = get_files("./examples") # print here(), files main_lib = core.create_block_factory(scan_dir=os.path.join(os.getcwd(), "library")) # all_in_one_arduino_dir = self.config.get("Path", "all_in_one_arduino_dir") libc_dir, tools_dir, boards_txt, target_files_dir = build.get_avr_arduino_paths() failed = [] succeeded = [] for fname in files : print here(), "loading:", fname local_lib = core.BasicBlocksFactory(load_basic_blocks=False) try : local_lib.load_standalone_workbench_lib(fname, "<local>") except Exception : print(here()) traceback.print_exc() failed.append((fname, "loading_as_library")) continue library = core.SuperLibrary([main_lib, local_lib]) w = dfs.Workbench(passive=True) try : with open(fname, "rb") as f : serializer.unpickle_workbench(f, w, use_cached_proto=False, library=library) except Exception : print(here()) traceback.print_exc() failed.append((fname, "loading_worbench")) continue sheets = w.sheets global_meta = w.get_meta() out_fobj = StringIO() try : libs_used, = implement.implement_workbench(w, sheets, global_meta, ccodegen, core.KNOWN_TYPES, library, out_fobj)#sys.stdout) except Exception : print(here()) traceback.print_exc() failed.append((fname, "implementing")) continue if out_fobj.tell() < 1 : print(here()) failed.append((fname, "no_code_generated")) continue source = out_fobj.getvalue() source_dirs = set() for l in library.libs : if l.name in libs_used : for src_file in l.source_files : source_dirs.add(os.path.dirname(src_file)) install_path = os.getcwd() blob_stream = StringIO() term_stream = StringIO() board_type = w.get_board() try : board_info = build.get_board_types()[board_type] variant = board_info["build.variant"] if "build.variant" in board_info else "standard" except Exception : print(here()) traceback.print_exc() failed.append((fname, "get_target_info")) continue try : rc, = build.build_source(board_type, source, aux_src_dirs=( (os.path.join(target_files_dir, "cores", "arduino"), False), (os.path.join(target_files_dir, "variants", variant), False), # (os.path.join(install_path, "library", "arduino"), False), ) + tuple( (path, True) for path in source_dirs ),#TODO derive from libraries used aux_idirs=[ os.path.join(install_path, "target", "arduino", "include") ], boards_txt=boards_txt, libc_dir=libc_dir, # board_db={}, ignore_file=None,#"amkignore", # ignore_lines=( "*.cpp", "*.hpp", "*" + os.path.sep + "main.cpp", ), #TODO remove this filter with adding cpp support to build.py ignore_lines=( "*" + os.path.sep + "main.cpp", ), # prog_port=None, # prog_driver="avrdude", # or "dfu-programmer" # prog_adapter="arduino", #None for dfu-programmer optimization="-Os", verbose=False, skip_programming=True,#False, # dry_run=False, blob_stream=blob_stream, term=term_stream) except Exception : print(here()) failed.append((fname, "build_failed")) continue succeeded.append((fname, )) finished = time.time() assert(len(failed) + len(succeeded) == len(files)) print("") print("done in {:.3}s, {} of {} failed".format(finished - started, len(failed), len(files))) print("") print("failed files:") pprint(failed)
# http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'tr-tr' SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale USE_L10N = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = here('assets/') # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = '/assets/' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = here('static') # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/'
('nl', 'Nederlands'), ) SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale USE_L10N = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = here('uploads/') # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = '/uploads/' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = here('static/') # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/'
def build_job(self, board_type, sheets, meta) : if board_type is None : self.__messages.put(("status", (("build", False, "board_type_not_set"), {}))) return None board_info = build.get_board_types()[board_type] variant = board_info["build.variant"] if "build.variant" in board_info else "standard" self.__messages.put(("status", (("build", True, "build_started"), {}))) w_data = serializer.get_workbench_data(self)#TODO refac build invocation out_fobj = StringIO() try : w = Workbench(passive=True, do_create_block_factory=False, blockfactory=self.blockfactory) local_lib = core.BasicBlocksFactory(load_basic_blocks=False) local_lib.load_standalone_workbench_lib(None, "<local>", library=w.blockfactory, w_data=w_data) library = core.SuperLibrary([w.blockfactory, local_lib]) serializer.restore_workbench(w_data, w, use_cached_proto=False, library=library) libs_used, = implement.implement_workbench(w, w.sheets, w.get_meta(), ccodegen, core.KNOWN_TYPES, library, out_fobj) except Exception as e: print(here(), traceback.format_exc()) self.__messages.put(("status", (("build", False, str(e)), {}))) return None if out_fobj.tell() < 1 : self.__messages.put(("status", (("build", False, "no_code_generated"), {}))) return None source = out_fobj.getvalue() print(source) all_in_one_arduino_dir = self.config.get("Path", "all_in_one_arduino_dir") libc_dir, tools_dir, boards_txt, target_files_dir = build.get_avr_arduino_paths( all_in_one_arduino_dir=all_in_one_arduino_dir) source_dirs = set() for l in library.libs : if l.name in libs_used : for src_file in l.source_files : source_dirs.add(os.path.dirname(src_file)) install_path = os.getcwd()#XXX replace os.getcwd() with path to dir with executable file blob_stream = StringIO() # term_stream = StringIO() # term_stream = sys.stdout term_stream = Workbench.TermStream(self.__messages) try : rc, = build.build_source(board_type, source, aux_src_dirs=( (os.path.join(target_files_dir, "cores", "arduino"), False), (os.path.join(target_files_dir, "variants", variant), False), # (os.path.join(install_path, "library", "arduino"), False), ) + tuple( (path, True) for path in source_dirs ),#TODO derive from libraries used aux_idirs=[ os.path.join(install_path, "target", "arduino", "include") ], boards_txt=boards_txt, libc_dir=libc_dir, # board_db={}, ignore_file=None,#"amkignore", # ignore_lines=( "*.cpp", "*.hpp", "*" + os.path.sep + "main.cpp", ), #TODO remove this filter with adding cpp support to build.py ignore_lines=( "*" + os.path.sep + "main.cpp", ), # prog_port=None, # prog_driver="avrdude", # or "dfu-programmer" # prog_adapter="arduino", #None for dfu-programmer optimization="-Os", verbose=False, skip_programming=True,#False, # dry_run=False, blob_stream=blob_stream, term=term_stream) except Exception as e : self.__messages.put(("status", (("build", False, "compilation_failed"), {"term_stream":str(e)}))) return None msg_info = {} # if term_stream != sys.stdout : # msg_info["term_stream"] = term_stream if rc : self.__blob = blob_stream.getvalue() self.__blob_time = time.time() else : self.__messages.put(("status", (("build", False, "compilation_failed"), msg_info))) return None # return (False, "build_failed") self.__messages.put(("status", (("build", True, ""), msg_info)))
'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ) ROOT_URLCONF = 'downforeveryoneorjustme.urls' TEMPLATE_DIRS = (here('templates'),) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'main', 'djcelery',
'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ) ROOT_URLCONF = 'downforeveryoneorjustme.urls' TEMPLATE_DIRS = (here('templates'), ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'main', 'djcelery', )
LANGUAGE_CODE = 'is' # "en-us" SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale USE_L10N = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = here('uploads/') # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = '/uploads/' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = here('static/') # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/'
SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale. USE_L10N = True # If you set this to False, Django will not use timezone-aware datetimes. USE_TZ = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = here('../static/uploads') # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = 'http://fatiherikli.com/static/uploads/' # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = '' # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/static/'
LANGUAGE_CODE = "is" # "en-us" SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale USE_L10N = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = here("uploads/") # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = "/uploads/" # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" STATIC_ROOT = here("static/") # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = "/static/"