J
J
Jekson2019-02-14 11:23:07
JavaScript
Jekson, 2019-02-14 11:23:07

How to launch an executable file from an external folder?

There is a project written in C and adapted to run through the Python darknet.py file . Now everything is run manually on the LAN. python darknet.py
All this is located in the darknet
folder. Next, a standard Flask project is deployed in the app folder. The structure looks like this:

project
    -darknet
        --darknet.py
        --__init__.py
        -- many other dirs and files
    -app
        --app.py
        --__init__.py
        --main.py

In darknet.py, everything is triggered by the call to the performDetect() function, which I want to use further in the web interface.
In app.py I write
from flask import Flask
from ..darknet.darknet import performDetect

app = Flask(__name__)

@app.route('/')
def index():
    performDetect()

main.py
from app import app

if __name__ == '__main__':
    app.run(debug=True)

But the interpreter complains about the
Traceback import (most recent call last):
File "main.py", line 1, in <module>
    from app import app
  File "/home/y700/projects/Alex_darknet/app/app.py", line 4, in <module>
    from .darknet.darknet import performDetect
ImportError: attempted relative import with no known parent package

How to properly run external files?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Timofeev, 2016-08-13
@webinar

naming js files differently makes no sense in them the functions are named the same. But id for calendars had to be different. Script 1 - id different and everything will work

A
Alexander Zolotykh, 2016-08-13
@zolotykh

  1. the first css and js must be connected once
  2. do not change the code and styles of the library
  3. see the documentation on how to connect multiple calendars at the same time

M
Maximys781, 2016-08-13
@Maximys781

Put different id and still nothing works.

<script>
  // Зададим стартовую дату
  var start = new Date(),
    prevDay,
    startHours = 9;

  // 09:00
  start.setHours(9);
  start.setMinutes(0);

  // Если сегодня суббота или воскресенье - 10:00
  if ([6,0].indexOf(start.getDay()) != -1) {
    start.setHours(10);
    startHours = 10
  }

  $('#timepicker-actions-exmpl').datepicker({
    timepicker: true,
    startDate: start,
    minHours: startHours,
    maxHours: 18,
    onSelect: function(fd, d, picker) {
      // Ничего не делаем если выделение было снято
      if (!d) return;

      var day = d.getDay();

      // Обновляем состояние календаря только если была изменена дата
      if (prevDay != undefined && prevDay == day) return;
      prevDay = day;

      // Если выбранный день суббота или воскресенье, то устанавливаем
      // часы для выходных, в противном случае восстанавливаем начальные значения
      if (day == 6 || day == 0) {
        picker.update({
          minHours: 10,
          maxHours: 16
        })
      } else {
        picker.update({
          minHours: 9,
          maxHours: 18
        })

            // Инициализация

      }
    }
  })
</script>

<script>
  // Зададим стартовую дату
  var start = new Date(),
    prevDay,
    startHours = 9;

  // 09:00
  start.setHours(9);
  start.setMinutes(0);

  // Если сегодня суббота или воскресенье - 10:00
  if ([6,0].indexOf(start.getDay()) != -1) {
    start.setHours(10);
    startHours = 10
  }

  $('#calendar-barber').datepickerbarber({
    timepickerbarber: true,
    startDatebarber: start,
    minHourses: startHours,
    maxHourses: 18,
    onSelect: function(fd, d, picker) {
      // Ничего не делаем если выделение было снято
      if (!d) return;

      var day = d.getDay();

      // Обновляем состояние календаря только если была изменена дата
      if (prevDay != undefined && prevDay == day) return;
      prevDay = day;

      // Если выбранный день суббота или воскресенье, то устанавливаем
      // часы для выходных, в противном случае восстанавливаем начальные значения
      if (day == 6 || day == 0) {
        picker.update({
          minHourses: 10,
          maxHourses: 16
        })
      } else {
        picker.update({
          minHourses: 9,
          maxHourses: 18
        })

            // Инициализация

      }
    }
  })
</script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question