Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

Reorganize project to match Node.js style #9

Merged
merged 2 commits into from
Feb 9, 2015

Conversation

tlrobinson
Copy link
Contributor

Changes described in #8. Currently a work in progress, the rest of the components and fbptest* need to be ported over.

jpaulm added a commit that referenced this pull request Feb 9, 2015
Reorganize project to match Node.js style
@jpaulm jpaulm merged commit d9f1c11 into jpaulm:master Feb 9, 2015
@jpaulm
Copy link
Owner

jpaulm commented Feb 9, 2015

Looks good, @tlrobinson ! Thanks! I will retest.

@jpaulm
Copy link
Owner

jpaulm commented Feb 9, 2015

Hi @tlrobinson - I'm having trouble getting JSFBP with your changes working. I have unzipped the current JSFBP zip file, but the result doesn't work. Before I start digging, I'm curious if you have more changes planned and/or if you tested the restructured project. I had assumed that, after a merge, everything continues to work - but maybe I did something wrong...? TIA

@tlrobinson
Copy link
Contributor Author

This PR is only partially complete, but running node examples/fbptest1.js should work. I didn't want to put in the effort to fix the rest of the tests until I was sure you'd be ok with the changes.

@tlrobinson
Copy link
Contributor Author

Also note you need to npm install each time you download a copy of the project since the dependencies are stored in node_modules (alternative you can do npm install -g fibers to install the fibers package globally).

However, typically you should just use git to check out a pull request branch. I can point you in the right direction if you'd like (basically git remote add tlrobinson [email protected]:tlrobinson/jsfbp.git then git fetch tlrobinson then git checkout tlrobinson/master)

@jpaulm
Copy link
Owner

jpaulm commented Feb 9, 2015

No, @tlrobinson, I keep getting

C:\Users\Paul\Documents\Business\node\node_modules\fibers\index.js:3
Fiber.prototype.fbpProc = null;
^
TypeError: Cannot set property 'fbpProc' of undefined
at Object.
(C:\Users\Paul\Documents\Business\node\node_modules\fi
bers\index.js:3:25)

Help!

Regards,

Paul

On Mon, Feb 9, 2015 at 1:45 PM, Tom Robinson [email protected]
wrote:

This PR is only partially complete, but running node examples/fbptest1.js
should work. I didn't want to put in the effort to fix the rest of the
tests until I was sure you'd be ok with the changes.


Reply to this email directly or view it on GitHub
#9 (comment).

@jpaulm
Copy link
Owner

jpaulm commented Feb 9, 2015

git remote add tlrobinson [email protected]:tlrobinson/jsfbp.git

failed - "not a git repository"

On Mon, Feb 9, 2015 at 1:54 PM, Tom Robinson [email protected]
wrote:

Also note you need to npm install each time you download a copy of the
project since the dependencies are stored in node_modules (alternative
you can do npm install -g fibers to install the fibers package globally).

However, typically you should just use git to check out a pull request
branch. I can point you in the right direction if you'd like (basically git
remote add tlrobinson [email protected]:tlrobinson/jsfbp.git then git fetch
tlrobinson then git checkout tlrobinson/master)


Reply to this email directly or view it on GitHub
#9 (comment).

@jpaulm
Copy link
Owner

jpaulm commented Feb 9, 2015

PS Clone doesn't appear to be set up for my project - the Clone button
doesn't do anything... am I doing something wrong?

Paul

On Mon, Feb 9, 2015 at 1:54 PM, Tom Robinson [email protected]
wrote:

Also note you need to npm install each time you download a copy of the
project since the dependencies are stored in node_modules (alternative
you can do npm install -g fibers to install the fibers package globally).

However, typically you should just use git to check out a pull request
branch. I can point you in the right direction if you'd like (basically git
remote add tlrobinson [email protected]:tlrobinson/jsfbp.git then git fetch
tlrobinson then git checkout tlrobinson/master)


Reply to this email directly or view it on GitHub
#9 (comment).

@tlrobinson
Copy link
Contributor Author

That's an odd error. Maybe you have a different version of the fibers package installed. Can you tell me what version is shown when you run npm show fibers? I have 1.0.5.

You need to run the git remote command within the Git repo (i.e. the directory containing the ".git" directory you get when you do "git clone [email protected]:jpaulm/jsfbp.git"). Zipped copies downloaded from GitHub don't have the ".git" metadata.

I'm not sure which clone button you're talking about. "Clone in Desktop"? You'd need to install GitHub's Mac or Windows app (mac.github.com or windows.github.com). I mostly just use the command line tools.

@jpaulm
Copy link
Owner

jpaulm commented Feb 10, 2015

git fetch tlrobinson failed -

C:\Users\Paul\Documents\GitHub\FBP-Repos\jsfbp-master> git fetch tlrobinson
The authenticity of host 'github.com (192.30.252.128)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.128' (RSA) to the list of
know
n hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

On Mon, Feb 9, 2015 at 1:54 PM, Tom Robinson [email protected]
wrote:

Also note you need to npm install each time you download a copy of the
project since the dependencies are stored in node_modules (alternative
you can do npm install -g fibers to install the fibers package globally).

However, typically you should just use git to check out a pull request
branch. I can point you in the right direction if you'd like (basically git
remote add tlrobinson [email protected]:tlrobinson/jsfbp.git then git fetch
tlrobinson then git checkout tlrobinson/master)


Reply to this email directly or view it on GitHub
#9 (comment).

@jpaulm
Copy link
Owner

jpaulm commented Feb 10, 2015

Nothing works now! Can't even install node-fibers! Does it work for you? If so, could you tell me the steps one by one, starting with a clean library?

Failing that, I will revert to the last good copy I had... or try to!

YIA

Paul

@jpaulm
Copy link
Owner

jpaulm commented Feb 10, 2015

PS @tlrobinson @ComFreek I seem to have gotten stuff working by sheer chance! What directory should I be in, prior to issuing npm install fibers ? TIA

@tlrobinson
Copy link
Contributor Author

That's odd... how have you been pushing code to GitHub before? Perhaps you were previously using the HTTP GitHub URLs rather than SSH? If you'd like to continue doing that you should do git remote add tlrobinson https://github.com/tlrobinson/jsfbp.git (you may have to do git remote rm tlrobinson to get rid of the old remote), though I think SSH is recommended.

You should be able to do npm install in the root directory of your repository, or any subdirectory (npm will look for a "package.json" in the current directory, then parent directories). To start from scratch just delete the "node_modules" directory that's in the root of the project (same directory as "package.json")

@tlrobinson
Copy link
Contributor Author

Also note if you just do "npm install" without a package name it will install all the dependencies listed in the package.json (with correct versions).

@jpaulm
Copy link
Owner

jpaulm commented Feb 10, 2015

Tried the git remotes as you suggested and got this (the debug log is
attached):

C:\Users\Paul\Documents\GitHub\FBP-Repos\jsfbp-master>npm install
|

[email protected] install
C:\Users\Paul\Documents\GitHub\FBP-Repos\jsfbp-master\nod
e_modules\fibers
node ./build.js

child_process: customFds option is deprecated, use stdio instead.

C:\Users\Paul\Documents\GitHub\FBP-Repos\jsfbp-master\node_modules\fibers>node
"
C:\Program Files
(x86)\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modu
les\node-gyp\bin\node-gyp.js" rebuild --release
child_process: customFds option is deprecated, use stdio instead.
Building the projects in this solution one at a time. To enable parallel
build,
please add the "/m" switch.
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.InvalidPlatform
.Targets(23,7): error MSB8007: The Platform for project 'fibers.vcxproj' is
inv
alid. Platform='x64'. You may be seeing this message because you are
trying to
build a project without a solution file, and have specified a non-default
Plat
form that doesn't exist for this project.
[C:\Users\Paul\Documents\GitHub\FBP-R
epos\jsfbp-master\node_modules\fibers\build\fibers.vcxproj]
gyp ERR! build error
gyp ERR! stack Error:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files
(x86)\nodejs\node_mo
dules\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit
(child_process.js:1067
:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\Program Files
(x86)\nodejs\node_modules\npm\nod
e_modules\node-gyp\bin\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd
C:\Users\Paul\Documents\GitHub\FBP-Repos\jsfbp-master\node_modules
fibers
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
Build failed
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files (x86)\nodejs\node.exe" "C:\Program
Files (
x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node ./build.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node ./build.js'.
npm ERR! This is most likely a problem with the fibers package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./build.js
npm ERR! You can get their info via:
npm ERR! npm owner ls fibers
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!
C:\Users\Paul\Documents\GitHub\FBP-Repos\jsfbp-master\npm-debug.log

C:\Users\Paul\Documents\GitHub\FBP-Repos\jsfbp-master>

TIA,

Paul M.

On Mon, Feb 9, 2015 at 9:13 PM, Tom Robinson [email protected]
wrote:

That's odd... how have you been pushing code to GitHub before? Perhaps you
were previously using the HTTP GitHub URLs rather than SSH? If you'd like
to continue doing that you should do git remote add tlrobinson
https://github.com/tlrobinson/jsfbp.git (you may have to do git remote rm
tlrobinson to get rid of the old remote), though I think SSH is
recommended.

You should be able to do npm install in the root directory of your
repository, or any subdirectory (npm will look for a "package.json" in the
current directory, then parent directories). To start from scratch just
delete the "node_modules" directory that's in the root of the project (same
directory as "package.json")


Reply to this email directly or view it on GitHub
#9 (comment).

@tlrobinson
Copy link
Contributor Author

This seems like a Windows-specific issue, and I don't have Windows, so I'm not sure how much I can help. Perhaps try installing an older version of node-fibers, e.x. npm install [email protected].

@jpaulm
Copy link
Owner

jpaulm commented Feb 10, 2015

@ComFreek - can you give me some instructions on how to (re)install? TIA Paul

@jpaulm
Copy link
Owner

jpaulm commented Feb 10, 2015

@laverdet I keep getting a message about missing solution file (see above) - can you point me at what I am doing wrong? Merci d'avance!

@ComFreek
Copy link
Collaborator

@jpaulm Strangely enough, I get similar errors. I cannot install fibers as well - irrespective of the working directory:

P:\blatest\node_modules\fibers>node "C:\ProgramData\chocolatey\lib\npm.1.4.9\tools\node_modules\npm\bin\node-gyp-bin\\..
\..\node_modules\node-gyp\bin\node-gyp.js" rebuild --release
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (C:\ProgramData\chocolatey\lib\npm.1.4.9\tools\node_modules\npm\node_modules\node-gyp
\lib\configure.js:103:14)
gyp ERR! stack     at C:\ProgramData\chocolatey\lib\npm.1.4.9\tools\node_modules\npm\node_modules\node-gyp\lib\configure
.js:64:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:99:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\ProgramData\\chocolatey\\lib\\npm.1.4.9\\tools\\node_modules\\npm\\node_modules\\node-gyp\\
bin\\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd P:\blatest\node_modules\fibers
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok
Build failed
npm ERR! [email protected] install: `node ./build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the fibers package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./build.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls fibers
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.3.9600
npm ERR! command "node" "C:\\ProgramData\\chocolatey\\lib\\npm.1.4.9\\tools\\node_modules\\npm\\bin\\npm-cli.js" "instal
l" "fibers"
npm ERR! cwd P:\blatest
npm ERR! node -v v0.12.0
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     P:\blatest\npm-debug.log
npm ERR! not ok code 0
PS P:\blatest>

Why do I have to have Python inside my PATH environment variable? It worked two days ago!
Maybe we should file an issue over at laverdet/node-fibers@GitHub.

@jpaulm
Copy link
Owner

jpaulm commented Feb 10, 2015

That's a big relief - I'm not the only one! I get somewhat different
messages but it still points at an error in fibers...

Thanks,

Paul

On Tue, Feb 10, 2015 at 10:45 AM, ComFreek [email protected] wrote:

@jpaulm https://github.com/jpaulm Strangely enough, I get similar
errors. I cannot install fibers as well - irrespective of the working
directory:

P:\blatest\node_modules\fibers>node "C:\ProgramData\chocolatey\lib\npm.1.4.9\tools\node_modules\npm\bin\node-gyp-bin..
..\node_modules\node-gyp\bin\node-gyp.js" rebuild --release
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at failNoPython (C:\ProgramData\chocolatey\lib\npm.1.4.9\tools\node_modules\npm\node_modules\node-gyp
\lib\configure.js:103:14)
gyp ERR! stack at C:\ProgramData\chocolatey\lib\npm.1.4.9\tools\node_modules\npm\node_modules\node-gyp\lib\configure
.js:64:11
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:99:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\ProgramData\chocolatey\lib\npm.1.4.9\tools\node_modules\npm\node_modules\node-gyp
bin\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd P:\blatest\node_modules\fibers
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok
Build failed
npm ERR! [email protected] install: node ./build.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the fibers package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./build.js
npm ERR! You can get their info via:
npm ERR! npm owner ls fibers
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.3.9600
npm ERR! command "node" "C:\ProgramData\chocolatey\lib\npm.1.4.9\tools\node_modules\npm\bin\npm-cli.js" "instal
l" "fibers"
npm ERR! cwd P:\blatest
npm ERR! node -v v0.12.0
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! P:\blatest\npm-debug.log
npm ERR! not ok code 0
PS P:\blatest>

Why do I have to have Python inside my PATH environment variable? It
worked two days ago!
Maybe we should file an issue over at laverdet/node-fibers@GitHub
https://github.com/laverdet/node-fibers.


Reply to this email directly or view it on GitHub
#9 (comment).

@tlrobinson
Copy link
Contributor Author

Looks like it's a node v0.12 issue. You could try rolling back to v0.11 for now.

@jpaulm
Copy link
Owner

jpaulm commented Feb 10, 2015

Hi @tlrobinson , that's fantastic! It worked! I'll update the install procedure in Readme - maybe you could check that I've stated it correctly...

fbptest1 worked - will you go ahead and convert the other examples or shall I? I also want to incorporate @ComFreek's style suggestions - do you want to go first? TIA

@tlrobinson
Copy link
Contributor Author

Great. I'll go ahead and convert them.

@tlrobinson
Copy link
Contributor Author

Which of the components would you consider reusable/generic enough to include in the components directory, versus the examples directory?

@jpaulm
Copy link
Owner

jpaulm commented Feb 11, 2015

Good question!

The following clearly should be test /example components:

copier_closing.js
copier_nonlooper.js
randdelay.js (although it could be useful for simulations, and to show how
to take time in a JSFBP component)
wssimproc.js

recvr.js should really be renamed to something like display - I can do that
if you like, as a number of networks reference it.

Not sure where chat1.html fits in...? Maybe another directory in examples?

Thanks again for doing all this!

Best regards,

Paul

On Wed, Feb 11, 2015 at 5:00 AM, Tom Robinson [email protected]
wrote:

Which of the components would you consider reusable/generic enough to
include in the components directory, versus the examples directory?


Reply to this email directly or view it on GitHub
#9 (comment).

@tlrobinson
Copy link
Contributor Author

Would logger be a good name for recvr? It uses console.log, after all.

Also it might be nice to add an optional configuration port called FORMAT or something that takes a printf style format string (if console.log is called with 2 or more arguments and the first argument has a format string like "%s" it will be formatted according to that format string). Are optional configuration ports possible? e.x. #19

@jpaulm
Copy link
Owner

jpaulm commented Feb 14, 2015

Yup, 'logger' would be good, I think. I can't really see how you use a
FORMAT IIP, though.

However, you reminded me that I haven't implemented optional input and
output ports yet. I'll add that to my todo list!

Thanks,

P.

On Fri, Feb 13, 2015 at 10:30 PM, Tom Robinson [email protected]
wrote:

Would logger be a good name for recvr? It uses console.log, after all.

Also it might be nice to add an optional configuration port called FORMAT
or something that takes a printf style format string (if console.log is
called with 2 or more arguments and the first argument has a format string
like "%s" it will be formatted according to that format string). Are
optional configuration ports possible? e.x. #19
#19


Reply to this email directly or view it on GitHub
#9 (comment).

@ComFreek
Copy link
Collaborator

I can't really see how you use a FORMAT IIP, though.

Let's say that the logger constantly receives integers from another component.
In the current implementation we would see the following output:

data: 1
data: 2
...

If we allow format strings to be applied, the component user can easily adjust the output to his needs. For example, one could set the format string to Amount of houses: %d. %d (formats the input as an integer) will be then replaced by the actual data which the logger received. Supported format strings are explained here: http://nodejs.org/api/util.html#util_util_format_format
Basically, it allows one to specify a text with a placeholder, which will eventually be replaced by the incoming data. Node.js' individual format strings are not that powerful because %s (string) and %d (integer and float) are not needed. We could simply have a single placeholder acting for them both since integers are automatically converted to strings by JS engines. The only interesting format string is %j for JSON output!

Note that only Node.js' version of console.log permits format strings (AFAIK).

@jpaulm
Copy link
Owner

jpaulm commented Feb 14, 2015

OK, I got that! It would mean, however, that one instance of recvr, soon
to be logger(?), would be needed for each output format - and the point
of loggers IMO is to provide a time sequence of any data that you need to
have logged.

Here is a portion (from a JavaFBP run):

2015-02-04T01:25:49:718 Process.IN: Receiving:
2015-02-04T01:25:49:733 Process.IN: Received: OPEN; pdata
2015-02-04T01:25:49:735 WSRcv.OUT: Sent OK
2015-02-04T01:25:49:736 Process.IN: Receiving:
2015-02-04T01:25:49:736 WSRcv.OUT: Sending: Client1: complist
2015-02-04T01:25:49:737 Process.IN: Received:
org.java_websocket.WebSocketImpl@7cac473d
2015-02-04T01:25:49:737 Process.IN: Receiving:
2015-02-04T01:25:49:737 Process: Recv/susp
2015-02-04T01:25:49:738 WSRcv.OUT: Sent OK
2015-02-04T01:25:49:738 Process: Recv/resume
2015-02-04T01:25:49:738 WSRcv.OUT: Sending: CLOSE; pdata
2015-02-04T01:25:49:739 Process.IN: Received: Client1: complist
2015-02-04T01:25:49:739 Process.IN: Receiving:
2015-02-04T01:25:49:739 Process: Recv/susp

On Sat, Feb 14, 2015 at 10:46 AM, ComFreek [email protected] wrote:

I can't really see how you use a FORMAT IIP, though.

Let's say that the logger constantly receives integers from another
component.
In the current implementation we would see the following output:

data: 1
data: 2
...

If we allow format strings to be applied, the component user can easily
adjust the output to his needs. For example, one could set the format
string to Amount of houses: %d. %d (formats the input as an integer) will
be then replaced by the actual data which the logger received. Supported
format strings are explained here:
http://nodejs.org/api/util.html#util_util_format_format
Basically, it allows one to specify a text with a placeholder, which will
eventually be replaced by the incoming data. Node.js' individual format
strings are not that powerful because %s (string) and %d (integer and
float) are not needed. We could simply have a single placeholder acting for
them both since integers are automatically converted to strings by JS
engines. The only interesting format string is %j for JSON output!

Note that only Node.js' version of console.log permits format strings
(AFAIK).


Reply to this email directly or view it on GitHub
#9 (comment).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants