Create localized django app and use the localization from other app - python-3.x

I have the following problem:
I created a Django app (app1) and then installed it in other one (app2). Now I'm trying to make the internationalization of the site, but I want to be able to use the installed app translations and I cannot even compile them.
Some useful information:
APP 1
.
├── MANIFEST.in
├── app1
│   ├── admin.py
│   ├── apps.py
│   ├── forms.py
│   ├── __init__.py
│   ├── locale/
│   │   ├── en-us
│   │   │   └── LC_MESSAGES
│   │   │   └── django.po
│   │   ├── es
│   │   │   └── LC_MESSAGES
│   │   │   └── django.po
│   │   └── pr
│   │   └── LC_MESSAGES
│   │   └── django.po
│   ├── migrations/
│   ├── models.py
│   ├── settings.py
│   ├── static/
│   ├── templates
│   ├── tests.py
│   ├── urls.py
│   ├── utils.py
│   └── views.py
└── setup.py
APP 2 (the one that has APP 1 installed)
├── app2/
│   ├── locale/
│   │   ├── en-us/
│   │   │   └── LC_MESSAGES
│   │   │   ├── django.mo
│   │   │   └── django.po
│   │   ├── es/
│   │   │   └── LC_MESSAGES
│   │   │   ├── django.mo
│   │   │   └── django.po
│   │   └── pr/
│   │   └── LC_MESSAGES
│   │   ├── django.mo
│   │   └── django.po
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app1.apps.App1SiteConfig',
'app2.apps.App2SiteConfig',
]
LANGUAGE_CODE = 'es'
LANGUAGES = (
('en-us', _('English')),
('es', _('Spanish')),
('pt', _('Portuguese'))
)
LOCALE_PATHS = (
os.path.join(BASE_DIR, "app2", "locale"),
)
Basically, the desired TODOs are:
compile the .mo's from App1
use the App1 transalations (it has its own templates and models so ideally they would be used there)
What I don't want:
compile the App1 .mo's from django-admin of App2 and then translate it there.
Thanks in advance!

Well.. finally I managed to solve this by my way..
With the virtualenv activated I moved to App1 dir and executed django-admin compilemessages, the .mo's has been created in the right path (app1/locale/<lang>/LC_MESSAGES/django.mo) and they're able to be used from the site.

Related

How to create .deb package from JavaFx project?

I wan't to create installer for my JavaFx application project (.deb package). I discovered that this can be done using intellij, but It's not working for my project. Deb package is created, but after installation my app is not running. Besides I wan't to customize this package. From the main debian page I read that I need to create a "control" file and with dpkg-deb --build I can create a package. But I don't know how to configure the "control" file and how to connect it all to the Main.java boot class or to the generated jar file. I'm looking for tips or advise how to do it best.
I used intellij to create a .deb package with it, but should this package be that big? (67MB) It is around 250MB to install. My .jar file with dependencies weighs 1.9MB. I have looked at this package and there are various libraries through which this package weighs so much (mainly amd64 and ext):
── lib
│   ├── amd64
│   │   ├── jli
│   │   │   └── libjli.so
│   │   ├── jvm.cfg
│   │   ├── libattach.so
│   │   ├── libavplugin-53.so
│   │   ├── libavplugin-54.so
│   │   ├── libavplugin-55.so
│   │   ├── libavplugin-56.so
│   │   ├── libavplugin-57.so
│   │   ├── libavplugin-ffmpeg-56.so
│   │   ├── libavplugin-ffmpeg-57.so
│   │   ├── libavplugin-ffmpeg-58.so
│   │   ├── libawt_headless.so
│   │   ├── libawt.so
│   │   ├── libawt_xawt.so
│   │   ├── libbci.so
│   │   ├── libdcpr.so
│   │   ├── libdecora_sse.so
│   │   ├── libdeploy.so
│   │   ├── libdt_socket.so
│   │   ├── libfontmanager.so
│   │   ├── libfxplugins.so
│   │   ├── libglassgtk2.so
│   │   ├── libglassgtk3.so
│   │   ├── libglass.so
│   │   ├── libglib-lite.so
│   │   ├── libgstreamer-lite.so
│   │   ├── libhprof.so
│   │   ├── libinstrument.so
│   │   ├── libj2gss.so
│   │   ├── libj2pcsc.so
│   │   ├── libj2pkcs11.so
│   │   ├── libjaas_unix.so
│   │   ├── libjava_crw_demo.so
│   │   ├── libjavafx_font_freetype.so
│   │   ├── libjavafx_font_pango.so
│   │   ├── libjavafx_font.so
│   │   ├── libjavafx_iio.so
│   │   ├── libjava.so
│   │   ├── libjawt.so
│   │   ├── libjdwp.so
│   │   ├── libjfr.so
│   │   ├── libjfxmedia.so
│   │   ├── libjfxwebkit.so
│   │   ├── libjpeg.so
│   │   ├── libjsdt.so
│   │   ├── libjsig.so
│   │   ├── libjsoundalsa.so
│   │   ├── libjsound.so
│   │   ├── liblcms.so
│   │   ├── libmanagement.so
│   │   ├── libmlib_image.so
│   │   ├── libnet.so
│   │   ├── libnio.so
│   │   ├── libnpt.so
│   │   ├── libprism_common.so
│   │   ├── libprism_es2.so
│   │   ├── libprism_sw.so
│   │   ├── libresource.so
│   │   ├── libsaproc.so
│   │   ├── libsctp.so
│   │   ├── libsplashscreen.so
│   │   ├── libsunec.so
│   │   ├── libt2k.so
│   │   ├── libunpack.so
│   │   ├── libverify.so
│   │   ├── libzip.so
│   │   └── server
│   │   ├── libjsig.so
│   │   ├── libjvm.so
│   │   └── Xusage.txt
│   ├── calendars.properties
│   ├── charsets.jar
│   ├── classlist
│   ├── cmm
│   │   ├── CIEXYZ.pf
│   │   ├── GRAY.pf
│   │   ├── LINEAR_RGB.pf
│   │   ├── PYCC.pf
│   │   └── sRGB.pf
│   ├── content-types.properties
│   ├── currency.data
│   ├── deploy.jar
│   ├── ext
│   │   ├── cldrdata.jar
│   │   ├── dnsns.jar
│   │   ├── jaccess.jar
│   │   ├── jfxrt.jar
│   │   ├── localedata.jar
│   │   ├── meta-index
│   │   ├── nashorn.jar
│   │   ├── sunec.jar
│   │   ├── sunjce_provider.jar
│   │   ├── sunpkcs11.jar
│   │   └── zipfs.jar
│   ├── flavormap.properties
│   ├── fontconfig.bfc
│   ├── fontconfig.properties.src
│   ├── fontconfig.RedHat.5.bfc
│   ├── fontconfig.RedHat.5.properties.src
│   ├── fontconfig.RedHat.6.bfc
│   ├── fontconfig.RedHat.6.properties.src
│   ├── fontconfig.SuSE.10.bfc
│   ├── fontconfig.SuSE.10.properties.src
│   ├── fontconfig.SuSE.11.bfc
│   ├── fontconfig.SuSE.11.properties.src
│   ├── fontconfig.Turbo.bfc
│   ├── fontconfig.Turbo.properties.src
│   ├── fonts
│   │   ├── fonts.dir
│   │   ├── LucidaBrightDemiBold.ttf
│   │   ├── LucidaBrightDemiItalic.ttf
│   │   ├── LucidaBrightItalic.ttf
│   │   ├── LucidaBrightRegular.ttf
│   │   ├── LucidaSansDemiBold.ttf
│   │   ├── LucidaSansRegular.ttf
│   │   ├── LucidaTypewriterBold.ttf
│   │   └── LucidaTypewriterRegular.ttf
│   ├── hijrah-config-umalqura.properties
│   ├── images
│   │   ├── cursors
│   │   │   ├── cursors.properties
│   │   │   ├── invalid32x32.gif
│   │   │   ├── motif_CopyDrop32x32.gif
│   │   │   ├── motif_CopyNoDrop32x32.gif
│   │   │   ├── motif_LinkDrop32x32.gif
│   │   │   ├── motif_LinkNoDrop32x32.gif
│   │   │   ├── motif_MoveDrop32x32.gif
│   │   │   └── motif_MoveNoDrop32x32.gif
│   │   └── icons
│   │   ├── sun-java_HighContrastInverse.png
│   │   ├── sun-java_HighContrast.png
│   │   ├── sun-java_LowContrast.png
│   │   └── sun-java.png
│   ├── javafx.properties
│   ├── javaws.jar
│   ├── jce.jar
│   ├── jexec
│   ├── jfr
│   │   ├── default.jfc
│   │   └── profile.jfc
│   ├── jfr.jar
│   ├── jfxswt.jar
│   ├── jsse.jar
│   ├── jvm.hprof.txt
│   ├── locale
│   │   ├── de
│   │   │   └── LC_MESSAGES
│   │   │   └── sunw_java_plugin.mo
│   │   ├── es
│   │   │   └── LC_MESSAGES
│   │   │   └── sunw_java_plugin.mo
│   │   ├── fr
│   │   │   └── LC_MESSAGES
│   │   │   └── sunw_java_plugin.mo
│   │   ├── it
│   │   │   └── LC_MESSAGES
│   │   │   └── sunw_java_plugin.mo
│   │   ├── ja
│   │   │   └── LC_MESSAGES
│   │   │   └── sunw_java_plugin.mo
│   │   ├── ko
│   │   │   └── LC_MESSAGES
│   │   │   └── sunw_java_plugin.mo
│   │   ├── ko.UTF-8
│   │   │   └── LC_MESSAGES
│   │   │   └── sunw_java_plugin.mo
│   │   ├── pt_BR
│   │   │   └── LC_MESSAGES
│   │   │   └── sunw_java_plugin.mo
│   │   ├── sv
│   │   │   └── LC_MESSAGES
│   │   │   └── sunw_java_plugin.mo
│   │   ├── zh
│   │   │   └── LC_MESSAGES
│   │   │   └── sunw_java_plugin.mo
│   │   ├── zh.GBK
│   │   │   └── LC_MESSAGES
│   │   │   └── sunw_java_plugin.mo
│   │   ├── zh_HK.BIG5HK
│   │   │   └── LC_MESSAGES
│   │   │   └── sunw_java_plugin.mo
│   │   ├── zh_TW
│   │   │   └── LC_MESSAGES
│   │   │   └── sunw_java_plugin.mo
│   │   └── zh_TW.BIG5
│   │   └── LC_MESSAGES
│   │   └── sunw_java_plugin.mo
│   ├── logging.properties
│   ├── management
│   │   ├── jmxremote.access
│   │   ├── jmxremote.password.template
│   │   ├── management.properties
│   │   └── snmp.acl.template
│   ├── management-agent.jar
│   ├── meta-index
│   ├── net.properties
│   ├── oblique-fonts
│   │   ├── fonts.dir
│   │   ├── LucidaSansDemiOblique.ttf
│   │   ├── LucidaSansOblique.ttf
│   │   ├── LucidaTypewriterBoldOblique.ttf
│   │   └── LucidaTypewriterOblique.ttf
│   ├── plugin.jar
│   ├── psfontj2d.properties
│   ├── psfont.properties.ja
│   ├── resources.jar
│   ├── rt.jar
│   ├── security
│   │   ├── blacklist
│   │   ├── blacklisted.certs
│   │   ├── cacerts
│   │   ├── java.policy
│   │   ├── java.security
│   │   ├── javaws.policy
│   │   ├── policy
│   │   │   ├── limited
│   │   │   │   ├── local_policy.jar
│   │   │   │   └── US_export_policy.jar
│   │   │   └── unlimited
│   │   │   ├── local_policy.jar
│   │   │   └── US_export_policy.jar
│   │   └── trusted.libraries
│   ├── sound.properties
│   └── tzdb.dat
these libraries are necessary, can I somehow reduce the size of this file?

How to make mtd-utils 2.0 for specified deployment path

I downloaded mtd-utils 2.0 and I want to built it for specified deployment path. If I launch:
./configure --bindir .../mtd-utils-81049e5/deploy/usr/sbin
and then I do:
make
I will get output into folder, where I launched make. I want to have executable files somewhere like: bla/mtd-utils-2.0.../deploy/usr/sbin...
IIUC, you can do this like that:
./configure --prefix=/tmp/mtd-utils
make
make install
Finally, you get this:
$ tree /tmp/mtd-utils
/tmp/mtd-utils
├── sbin
│   ├── doc_loadbios
│   ├── docfdisk
│   ├── flash_erase
│   ├── flash_eraseall
│   ├── flash_lock
│   ├── flash_otp_dump
│   ├── flash_otp_info
│   ├── flash_otp_lock
│   ├── flash_otp_write
│   ├── flash_unlock
│   ├── flashcp
│   ├── ftl_check
│   ├── ftl_format
│   ├── jffs2dump
│   ├── jffs2reader
│   ├── mkfs.jffs2
│   ├── mkfs.ubifs
│   ├── mtd_debug
│   ├── mtdinfo
│   ├── mtdpart
│   ├── nanddump
│   ├── nandtest
│   ├── nandwrite
│   ├── nftl_format
│   ├── nftldump
│   ├── recv_image
│   ├── rfddump
│   ├── rfdformat
│   ├── serve_image
│   ├── sumtool
│   ├── ubiattach
│   ├── ubiblock
│   ├── ubicrc32
│   ├── ubidetach
│   ├── ubiformat
│   ├── ubimkvol
│   ├── ubinfo
│   ├── ubinize
│   ├── ubirename
│   ├── ubirmvol
│   ├── ubirsvol
│   └── ubiupdatevol
└── share
└── man
├── man1
│   └── mkfs.jffs2.1
└── man8
└── ubinize.8
5 directories, 44 files

NodeJS Express Docker Instance exited with code 0

Goal
I have 3 instances in my dockercompose.yml , I can only start 2 of my instances, and have a hard time starting my third one which my node express.
Project directory
.
├── Icon\r
├── angular
│   ├── Dockerfile
│   ├── README.md
│   ├── dist
│   │   ├── css
│   │   │   └── style.css
│   │   ├── img
│   │   │   ├── external.png
│   │   │   ├── favicon.png
│   │   │   ├── footer_logo.png
│   │   │   └── logo.png
│   │   ├── index.html
│   │   └── js
│   │   ├── bundle.js
│   │   └── vendor.js
│   ├── docs
│   │   ├── app
│   │   │   ├── api.js
│   │   │   ├── app.config.js
│   │   │   ├── app.module.js
│   │   │   └── guide.js
│   │   ├── build
│   │   │   ├── index.html
│   │   │   ├── partials
│   │   │   │   ├── api
│   │   │   │   │   ├── common
│   │   │   │   │   │   ├── directive
│   │   │   │   │   │   │   └── app.html
│   │   │   │   │   │   ├── directive.html
│   │   │   │   │   │   ├── type
│   │   │   │   │   │   │   ├── AppController.html
│   │   │   │   │   │   │   └── AppSidebarController.html
│   │   │   │   │   │   └── type.html
│   │   │   │   │   ├── common.html
│   │   │   │   │   ├── components.auth
│   │   │   │   │   │   ├── service
│   │   │   │   │   │   │   └── AuthService.html
│   │   │   │   │   │   └── service.html
│   │   │   │   │   ├── components.auth.html
│   │   │   │   │   ├── components.contact
│   │   │   │   │   │   ├── directive
│   │   │   │   │   │   │   └── lengthCheck.html
│   │   │   │   │   │   ├── directive.html
│   │   │   │   │   │   ├── service
│   │   │   │   │   │   │   └── ContactService.html
│   │   │   │   │   │   ├── service.html
│   │   │   │   │   │   ├── type
│   │   │   │   │   │   │   └── ContactEditController.html
│   │   │   │   │   │   └── type.html
│   │   │   │   │   ├── components.contact.html
│   │   │   │   │   └── components.html
│   │   │   │   ├── api.html
│   │   │   │   ├── guide
│   │   │   │   │   └── howTo.html
│   │   │   │   └── guide.html
│   │   │   └── src
│   │   │   ├── api-data.js
│   │   │   ├── api.js
│   │   │   ├── app.config.js
│   │   │   ├── app.module.js
│   │   │   ├── guide-data.js
│   │   │   └── guide.js
│   │   ├── config
│   │   │   ├── index.js
│   │   │   ├── processors
│   │   │   │   ├── api-data.js
│   │   │   │   ├── guide-data.js
│   │   │   │   └── index-page.js
│   │   │   └── templates
│   │   │   ├── constant-data.template.js
│   │   │   ├── content.template.html
│   │   │   ├── indexPage.template.html
│   │   │   └── module.template.html
│   │   └── content
│   │   ├── api
│   │   │   └── index.md
│   │   └── guide
│   │   ├── howTo.md
│   │   └── index.md
│   ├── files
│   │   ├── default.conf
│   │   └── nginx.conf
│   ├── gulpfile.babel.js
│   ├── karma.conf.js
│   ├── mocks
│   │   └── firebase.mock.js
│   ├── npm-shrinkwrap.json
│   ├── package.json
│   ├── src
│   │   ├── app
│   │   │   ├── common
│   │   │   │   ├── app-footer.component.js
│   │   │   │   ├── app-footer.html
│   │   │   │   ├── app-header.component.js
│   │   │   │   ├── app-header.html
│   │   │   │   ├── app-pagination.html
│   │   │   │   ├── app-pagination.js
│   │   │   │   ├── app-sidebar.component.js
│   │   │   │   ├── app-sidebar.html
│   │   │   │   ├── app.component.js
│   │   │   │   ├── app.html
│   │   │   │   ├── app.module.js
│   │   │   │   ├── app.spec.js
│   │   │   ├── components
│   │   │   │   ├── auth
│   │   │   │   │   ├── auth-form
│   │   │   │   │   │   ├── auth-form.component.js
│   │   │   │   │   │   ├── auth-form.controller.js
│   │   │   │   │   │   ├── auth-form.html
│   │   │   │   │   │   └── auth-form.spec.js
│   │   │   │   │   ├── auth.module.js
│   │   │   │   │   ├── auth.spec.js
│   │   │   │   │   └── login
│   │   │   │   │   ├── login.component.js
│   │   │   │   │   ├── login.controller.js
│   │   │   │   │   ├── login.html
│   │   │   │   │   └── login.spec.js
│   │   │   │   ├── components.module.js
│   │   │   │   └── dashboard
│   │   │   │   ├── access-point-map
│   │   │   │   │   ├── access-point-map.component.js
│   │   │   │   │   └── access-point-map.html
│   │   │   │   ├── account-stats
│   │   │   │   │   ├── account-stats.component.js
│   │   │   │   │   └── account-stats.html
│   │   │   │   ├── dashboard.component.js
│   │   │   │   └── dashboard.html
│   │   │   ├── root.component.js
│   │   │   ├── root.html
│   │   │   └── services
│   │   │   ├── account.service.js
│   │   │   ├── auth.service.js
│   │   │   └── services.module.js
│   │   ├── img
│   │   │   ├── external.png
│   │   │   ├── favicon.png
│   │   │   ├── footer_logo.png
│   │   │   └── logo.png
│   │   ├── index.html
│   │   └── sass
│   │   ├── base
│   │   │   ├── _buttons.scss
│   │   │   ├── _forms.scss
│   │   │   ├── _headings.scss
│   │   │   ├── _list-group.scss
│   │   │   ├── _main.scss
│   │   │   ├── _media.scss
│   │   │   ├── _mixins.scss
│   │   │   ├── _page-header.scss
│   │   │   ├── _scaffolding.scss
│   │   │   ├── _sections.scss
│   │   │   ├── _table.scss
│   │   │   └── _tabset.scss
│   │   ├── components
│   │   │   ├── _auth.scss
│   │   │   ├── _footer.scss
│   │   │   ├── _header.scss
│   │   │   ├── _panels.scss
│   │   │   ├── _root.scss
│   │   │   ├── _sidebar.scss
│   │   │   └── _tablet.scss
│   │   ├── layout
│   │   │   ├── _loading.scss
│   │   │   └── _smb.scss
│   │   ├── style.scss
│   │   ├── utils
│   │   │   ├── _colors.scss
│   │   │   └── _typography.scss
│   │   └── vendors
│   │   ├── _bootstrap.scss
│   │   ├── _colorpicker.scss
│   │   ├── _fontawesome.scss
│   │   └── _rzslider.scss
│   └── templates.js
├── docker-compose.yml
└── express
├── Dockerfile
├── LICENSE
├── README.md
├── bin
│   └── index.js
├── npm-debug.log
├── npm-shrinkwrap.json
├── package.json
└── server
├── app.js
├── config
│   └── config.json
├── controllers
│   ├── accounts.js
│   ├── auth.js
│   ├── index.js
│   ├── todoitems.js
│   └── todos.js
├── migrations
│   ├── 20160717103305-create-todo.js
│   └── 20160717104733-create-todo-item.js
├── models
│   ├── index.js
│   ├── todo.js
│   └── todoitem.js
├── routes
│   └── index.js
└── services
├── account.js
├── cpe.js
├── device.js
└── index.js
59 directories, 166 files
Back-end
Dockerfile
# Create image based on the official Node 6 image from the dockerhub
FROM node:6
RUN useradd --user-group --create-home --shell /bin/false nodejs
# Create a directory where our app will be placed
RUN mkdir -p /usr/src/app
# Change directory so that our commands run inside this new directory
WORKDIR /usr/src/app
# Copy dependency definitions
COPY package.json /usr/src/app
# Install dependecies
RUN npm install
# Get all the code needed to run the app
COPY . /usr/src/app
# Expose the port the app runs in
EXPOSE 3000
# Serve the app
CMD ["node", "server/app.js"]
Do I have any bug in this file above according to my file structure ?
Front-end
Dockerfile
FROM alpine:3.6
RUN apk add --update nginx && rm -rf /var/cache/apk/*
RUN mkdir -p /tmp/nginx/client-body
COPY files/nginx.conf /etc/nginx/nginx.conf
COPY files/default.conf /etc/nginx/conf.d/default.conf
COPY dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
dockercompose.yml
version: '2.1'
# Define the services/containers to be run
services:
angular:
build: angular # specify the directory of the Dockerfile
network_mode: bridge
ports:
- 8080:80/tcp
volumes:
- /Users/bheng/Sites/BASE/angular/dist:/usr/share/nginx/html:rw
express: #name of the second service
build: express # specify the directory of the Dockerfile
ports:
- "3000:3000" #specify ports forewarding
mem_limit: 300m
memswap_limit: 1g
volumes:
- .:/home/nodejs/app
- /home/nodejs/app/node_modules
links:
- database
database: # name of the third service
image: postgres
environment:
POSTGRES_PASSWORD: ih4cku
ports:
- "5432:5432" # specify port forewarding
Result
I couldn't get my third instances to start.
I kept getting
docker-compose up
Starting base_angular_1 ...
Starting base_database_1 ...
Starting base_database_1
Starting base_database_1 ... done
Starting base_express_1 ...
Starting base_express_1 ... done
Attaching to base_angular_1, base_database_1, base_express_1
database_1 | LOG: database system was shut down at 2017-08-30 00:54:24 UTC
database_1 | LOG: MultiXact member wraparound protections are now enabled
database_1 | LOG: database system is ready to accept connections
database_1 | LOG: autovacuum launcher started
base_express_1 exited with code 0
How would one go about and debug this further?
ok, after you posted your app.js, I think I can help you.
When you run node app.js, that app.js is being executed and exiting successfully because it is just a module but no server is starting.
You need a file like this:
create a bin folder and inside create a file, name this file www
Names are just suggestions, you can name it whatever.
#!/usr/bin/env node
/**
* Load any undefined ENV variables
*/
require('dotenv').config();
/**
* Module dependencies.
*/
var app = require('../app');
var debug = require('debug')('app:server');
var http = require('http');
/**
* Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
}
/**
* Event listener for HTTP server "error" event.
*/
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}
/**
* Event listener for HTTP server "listening" event.
*/
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
Then make sure you install these packages:
npm install debug --save
npm install dotenv --save
These can be removed from the www file, if you want. I just included them here so my shared www file runs.
Then, in your Dockerfile for the express app, use:
node ./bin/www
This command starts a server, keeps the process alive and serves your app.js express module. Make sure that where you require the app.js file in the www, matches the location of your file. I put there ../app in the require.
How to include it in DockerFile?
I recommend this:
create a start entry in your package.json:
"start": "node ./bin/www"
in the scripts section.
Then, update your Dockerfile:
CMD npm start or CMD ["npm", "start"]

Python3.5 recursive glob not showing matching files

With Pyton >= 3.5 glob supports recursive searching. I am attempting to do this, but with no success.
Here you can see my directory structure:
/Volumes/user/TEST/
└── [NAME]john\ doe,\ peter\ griffin\ -\ sample\ video[29.06.17][1080]{user}
├── [NAME]john\ doe,\ perter\ griffin\ -\ sample\ video[29.06.17][1080]{user}.mp4
├── [NAME]john\ doe,\ peter\ griffin\ -\ sample\ video[29.06.17][Hi-Res]
│   ├── 583a6ea574035-img-8399.jpg
│   ├── 583a6eb9681c0-img-8401.jpg
│   ├── 583a6eb9e53e1-img-8402.jpg
│   ├── 583a6ecad078d-img-8404.jpg
│   ├── 583a6ecd207ed-img-8403.jpg
│   ├── 583a6edb7348c-img-8405.jpg
│   ├── 583a6ede1cbfa-img-8406.jpg
│   ├── 583a6eeb294a9-img-8407.jpg
│   ├── 583a6eee94a45-img-8408.jpg
│   ├── 583a6efb2389a-img-8409.jpg
│   ├── 583a6f01a78ae-img-8410.jpg
│   ├── 583a6f0daea30-img-8411.jpg
│   ├── 583a6f1301e3c-img-8412.jpg
│   ├── 583a6f1ec07d8-img-8413.jpg
│   ├── 583a6f240d4ce-img-8414.jpg
│   ├── 583a6f306f517-img-8415.jpg
│   ├── 583a6f36def7a-img-8416.jpg
│   ├── 583a6f4280706-img-8417.jpg
│   ├── 583a6f48b8b11-img-8418.jpg
│   ├── 583a6f55160cc-img-8419.jpg
│   ├── 583a6f5b7fb35-img-8420.jpg
│   ├── 583a6f68aad40-img-8423.jpg
│   ├── 583a6f6da8c0b-img-8424.jpg
│   ├── 583a6f7b9e1d6-img-8425.jpg
│   ├── 583a6f8069e59-img-8426.jpg
│   ├── 583a6f8e9891e-img-8427.jpg
│   ├── 583a6f9427910-img-8428.jpg
│   ├── 583a6fa45e3f4-img-8429.jpg
│   ├── 583a6fa96b182-img-8430.jpg
│   ├── 583a6fb935bf2-img-8431.jpg
│   ├── 583a6fca7a0c9-img-8433.jpg
│   ├── 583a6fcbab549-img-8434.jpg
│   ├── 583a6fdcf2812-img-8435.jpg
│   ├── 583a6fde5ee86-img-8436.jpg
│   ├── 583a6fee54d9b-img-8437.jpg
│   ├── 583a6ff0acb76-img-8438.jpg
│   ├── 583a7000ecd80-img-8439.jpg
│   ├── 583a70026c325-img-8440.jpg
│   ├── 583a701319c22-img-8441.jpg
│   ├── 583a701457221-img-8443.jpg
│   ├── 583a7027e8531-img-8444.jpg
│   ├── 583a7029f0e7c-img-8445.jpg
│   ├── 583a703d6c3c9-img-8446.jpg
│   ├── 583a703f879f5-img-8447.jpg
│   ├── 583a7051ae77a-img-8448.jpg
│   ├── 583a705b588c3-img-8449.jpg
│   ├── 583a706d40811-img-8450.jpg
│   ├── 583a7076cb3e9-img-8451.jpg
│   ├── 583a70894ec35-img-8452.jpg
│   ├── 583a70964fbcb-img-8453.jpg
│   ├── cai-8498-pa.jpg
│   └── cai-8498-pt.jpg
├── [NAME]john\ doe,\ peter\ griffin\ -\ sample\ video[29.06.17][Hi-Res].jpg
└── cover.png
So the images are definitely there.
Now here is my method, that for some reason, is not working:
def count_images(folder):
"""
Count the number of images in a folder.
:param folder: Folder to count the images
:return: Number of photos
"""
print(folder)
files = [file for file in glob.glob(folder + '/**/*.jpg', recursive=True)]
print(files)
return len([file for file in glob.glob(folder + '/**/*.jpg', recursive=True)])
But it just outputs the following:
/Volumes/user/TEST/[NAME]john doe, peter griffin - sample video[29.06.17][1080]{user}/
[]
It is becoming extremely frustrating, as I do not see what I am doing wrong.
So I found the problem.
The glob module has issues with certain characters in the filename - [ and ] in this case. You can use glob.escape() to escape these characters in the filename.
So the final function will look like this:
def count_images(folder):
return len([file for file in glob.glob(glob.escape(folder) + '/**/*.jpg', recursive=True)])

Correct way of starting a NodeJs, React project with Express

I'm beginning with React, NodeJs and ExpressJs. I have seen many tutorials but I'm not sure of the correct way to start a project?
I have seen two ways. The first being express <project_name> and the second being npm init.
Which is correct and if there isn't a correct way then why would you initialize them differently when npm init includes express eventually (In the tutorials).
Thanks
npm init is good way to start, as you know it creates a package.json file in your project directory where you can store your project dependencies.
After this you must run the following commands:
npm install --save-dev webpack
npm install --save-dev babel
npm install --save-dev babel-loader
npm install babel-core
npm install babel-preset-env
npm install babel-preset-react
or as a single line command use this:
npm install --save-dev webpack babel babel-loader babel-core babel-preset-env babel-preset-react
first command will create a webpack.config.js file.
Second command will ready the babel to use in your project and the third to use babel-loader.
Now it's time to create project structure which looks like :
projectFolder/
├── package.json
├── public
│   ├── favicon.ico
│   └── index.html
├── README.md
└── src
├── App.css
├── App.js
├── App.test.js
├── index.css
├── index.js
└── logo.png
This is the very basic project structure. It doesn't have server side structure.
full structure looks like:
react/
├── CHANGELOG.md
├── CONTRIBUTING.md
├── docs
│   ├── data-fetching.md
│   ├── getting-started.md
│   ├── how-to-configure-text-editors.md
│   ├── react-style-guide.md
│   ├── README.md
│   └── recipes/
├── LICENSE.txt
├── node_modules/
├── package.json
├── README.md
├── src
│   ├── actions
│   ├── client.js
│   ├── components
│   │   ├── App
│   │   │   ├── App.js
│   │   │   ├── App.scss
│   │   │   ├── package.json
│   │   │   └── __tests__
│   │   │   └── App-test.js
│   │   ├── ContentPage
│   │   │   ├── ContentPage.js
│   │   │   ├── ContentPage.scss
│   │   │   └── package.json
│   │   ├── ErrorPage
│   │   │   ├── ErrorPage.js
│   │   │   ├── ErrorPage.scss
│   │   │   └── package.json
│   │   ├── Feedback
│   │   │   ├── Feedback.js
│   │   │   ├── Feedback.scss
│   │   │   └── package.json
│   │   ├── Footer
│   │   │   ├── Footer.js
│   │   │   ├── Footer.scss
│   │   │   └── package.json
│   │   ├── Header
│   │   │   ├── Header.js
│   │   │   ├── Header.scss
│   │   │   ├── logo-small#2x.png
│   │   │   ├── logo-small.png
│   │   │   └── package.json
│   │   ├── Link
│   │   │   ├── Link.js
│   │   │   └── package.json
│   │   ├── Navigation
│   │   │   ├── Navigation.js
│   │   │   ├── Navigation.scss
│   │   │   └── package.json
│   │   ├── NotFoundPage
│   │   │   ├── NotFoundPage.js
│   │   │   ├── NotFoundPage.scss
│   │   │   └── package.json
│   │   ├── TextBox
│   │   │   ├── package.json
│   │   │   ├── TextBox.js
│   │   │   └── TextBox.scss
│   │   ├── variables.scss
│   │   └── withViewport.js
│   ├── config.js
│   ├── constants
│   │   └── ActionTypes.js
│   ├── content
│   │   ├── about.jade
│   │   ├── index.jade
│   │   └── privacy.jade
│   ├── core
│   │   ├── db.js
│   │   ├── DOMUtils.js
│   │   ├── fetch
│   │   │   ├── fetch.client.js
│   │   │   ├── fetch.server.js
│   │   │   └── package.json
│   │   ├── Location.js
│   │   └── passport.js
│   ├── data
│   │   ├── queries
│   │   │   ├── content.js
│   │   │   ├── me.js
│   │   │   └── news.js
│   │   ├── schema.js
│   │   └── types
│   │   ├── ContentType.js
│   │   ├── NewsItemType.js
│   │   └── UserType.js
│   ├── public
│   │   ├── apple-touch-icon.png
│   │   ├── browserconfig.xml
│   │   ├── crossdomain.xml
│   │   ├── favicon.ico
│   │   ├── humans.txt
│   │   ├── robots.txt
│   │   ├── tile.png
│   │   └── tile-wide.png
│   ├── routes
│   │   ├── contact
│   │   │   ├── Contact.js
│   │   │   ├── Contact.scss
│   │   │   └── index.js
│   │   ├── home
│   │   │   ├── Home.js
│   │   │   ├── Home.scss
│   │   │   └── index.js
│   │   ├── login
│   │   │   ├── index.js
│   │   │   ├── Login.js
│   │   │   └── Login.scss
│   │   └── register
│   │   ├── index.js
│   │   ├── Register.js
│   │   └── Register.scss
│   ├── routes.js
│   ├── server.js
│   ├── stores
│   └── views
│   ├── error.jade
│   └── index.jade
├── test
│   └── stubs
│   └── SCSSStub.js
└── tools
├── build.js
├── bundle.js
├── clean.js
├── copy.js
├── deploy.js
├── lib
│   ├── fetch.js
│   └── fs.js
├── README.md
├── run.js
├── runServer.js
├── start.js
└── webpack.config.js
Created using yeoman generator-react-fullstack
Alternatively you can do all this stuff by simply using yeoman react generator but be careful with generators, they sometimes toughen your deployment process.

Resources