Urban75 Home About Offline BrixtonBuzz Contact

Help Any Python or Ruby people here? Files won't run

The gemfile thing is supposed to be bundle a load of software.
None of the ruby commands work directly in the cd prompt (are they supposed to?), they just say file not found.
Ok, I think you might have to retrace your steps and start again from the beginning.
I'm not sure exactly what you're trying to do however before you can run ruby or python script you need to make sure that they can be run from the command prompt from any folder on your pc. In order to do that you need to 1. install ruby/python 2.add them to the path then 3.verify that they have been installed correctly with a "ruby -v" or "python --version" command. None of your screenshot does not show you running ruby from the command line to verify that it works and you'll need to do that before you can do anything else.
 
They do even if you cannot see it. There is a menu choice to show files PLUS extensions (they are hidden by default) you must find it and change them else it is pointless doing anything else

Ah right, found that and done that, thanks.

I can't work out the rest though. I probably just need to sleep.
 
Ok, I think you might have to retrace your steps and start again from the beginning.
I'm not sure exactly what you're trying to do however before you can run ruby or python script you need to make sure that they can be run from the command prompt from any folder on your pc. In order to do that you need to 1. install ruby/python 2.add them to the path then 3.verify that they have been installed correctly with a "ruby -v" or "python --version" command. None of your screenshot does not show you running ruby from the command line to verify that it works and you'll need to do that before you can do anything else.

It is installed. Isn't it?
upload_2018-4-4_23-36-26.png
 
It is installed. Isn't it?
View attachment 131902
Er...ok...well yes it is installed, however ruby puts 'jello world' isn't a valid command.
upload_2018-4-4_23-40-48.png
...and neither is "C:\\Ruby24-x64\\Gemfile".

It could be that your tumblr_auth.rb ruby file is really a tumblr_auth.rb.txt file. If you've saved it with notepad you may have created a file with a ".txt" extension.
 
Alan - editplus.

Er...ok...well yes it is installed, however ruby puts 'jello world' isn't a valid command.
View attachment 131903
...and neither is "C:\\Ruby24-x64\\Gemfile".

It could be that your tumblr_auth.rb ruby file is really a tumblr_auth.rb.txt file. If you've saved it with notepad you may have created a file with a ".txt" extension.

I didn't think ruby puts jello world was a valid command, but one of you told me to put my ruby commands directly in the command prompt, so I did, as an experiment. I've basically got to the random keyboard bashing stage since following actual instructions doesn't seem to do much better.

My tumblr_auth.rb file really is a Ruby file - it was created as a Ruby file, saved as a Ruby file and still says it's a Ruby file (and only Ruby file, no .txt) now that I've enabled viewing hidden extensions. This is one of the few things I'm sure of here :D
 
I have often found that creating new setups and getting things running to be a bigger pain than the programming itself. But, once it is done, it is done and then you can cut and paste the script straight in. If you do not have it sussed by tomorrow I will go through it step by step with you. It wont take much as you are almost there. A simple typo can stop everything and it is such a frustrating experience.
 
Alan - editplus.



I didn't think ruby puts jello world was a valid command, but one of you told me to put my ruby commands directly in the command prompt, so I did, as an experiment. I've basically got to the random keyboard bashing stage since following actual instructions doesn't seem to do much better.

My tumblr_auth.rb file really is a Ruby file - it was created as a Ruby file, saved as a Ruby file and still says it's a Ruby file (and only Ruby file, no .txt) now that I've enabled viewing hidden extensions. This is one of the few things I'm sure of here :D
Ok, well it looks like your tumblr_auth.rb script has an error in it...

upload_2018-4-5_0-1-49.png

wth is that "// Authenticate" bit doing there?

Ruby comments start with a "#" not a "//".
 
Alan - editplus.
Editplus is ok, but it's a bit oldschool. If your editplus installation had ruby syntax support then it should give you visual cues with syntax colouring so you can easily distinguish keywords, comments and strings. My current editor of choice is Visual Studio Code which has good support for most of the major languages and is free. (I have paid for Sublime Text and UltraEdit and EditPlus in the past)
 
Editplus is ok, but it's a bit oldschool. If your editplus installation had ruby syntax support then it should give you visual cues with syntax colouring so you can easily distinguish keywords, comments and strings. My current editor of choice is Visual Studio Code which has good support for most of the major languages and is free. (I have paid for Sublime Text and UltraEdit and EditPlus in the past)

Yeah, it does have the colours. I'm comfortable with it and don't really want to get used to a new text editor when I'm struggling with code at the same time.

I'm going to sleep for a bit and try again tomorrow.
 
Yeah, it does have the colours. I'm comfortable with it and don't really want to get used to a new text editor when I'm struggling with code at the same time.

I'm going to sleep for a bit and try again tomorrow.
Fair enough. Leaving the editor choice to one side for a moment, I think there are some basic principles that you might want to get a bit more familiar with otherwise I suspect that you may be in for a bit more frustration especially if you are trying to follow somebody else's instructions without that basic understanding.
 
I've never written ruby on Windows only Linux machines but unexpected tCONSTANT means an improperly terminated string go through your code and look for one of " ' or ` (double quote, single quote or backtick) that you can't find a matching one on the same line.
 
I've never written ruby on Windows only Linux machines but unexpected tCONSTANT means an improperly terminated string go through your code and look for one of " ' or ` (double quote, single quote or backtick) that you can't find a matching one on the same line.
It looks like it's the "// Authenticate via 0Auth" that causing that particular error.
I presume it was meant to be a comment but ruby uses "#" for comments and not "//".
 
In fact thinking on start at the word Authenticate and work backwards, Ruby variables are declared implicitly so any word that is not a keyword is potentially a variable, Authenticate isn't a ruby keyword so the interpreter is treating it as an undefined constant which always begin with an uppercase, regular variables should all be lowercase. The missing doofer will be probably be the line before it.
 
It looks like it's the "// Authenticate via 0Auth" that causing that particular error.
I presume it was meant to be a comment but ruby uses "#" for comments and not "//".

It does look like that, but the comments have a #.

I've never written ruby on Windows only Linux machines but unexpected tCONSTANT means an improperly terminated string go through your code and look for one of " ' or ` (double quote, single quote or backtick) that you can't find a matching one on the same line.

That's what I thought, but I can't see anything. But they can be hard to spot I guess.

This is the whole thing:

require 'tumblr_client'

# Authenticate via OAuth
client = Tumblr::Client.new({
:consumer_key => 'M5CYUxMjtwFkt6z0USEWU7DEU4UK3ijNj5dGA26vtgfft6c79M',
:consumer_secret => 'xeP1XnCqxyFfUz1JmI3caN3FBeh2ZS1uvgtuMvpVH5xWH6sKei',
:oauth_token => 'lSBa4vn4whF8rsTFtTCGGg3xzmBxEbpqTfKBEuA4gjwiGy9MK1',
:oauth_token_secret => '2uy3wWmLackUbF7EYEAnAy0SBBUwyrbPwTK3dHCfcC4kBBmRAq'
})

# Make the request
puts 'client.info'

Now the gem file is saying it doesn't have write permissions, which is odd because I've given it write permissions.
 
A require statement is the Ruby version of the include statement in other languages, On Linux machines it must end in .rb even though filetypes aren't significant and the path must be specified even if it is in the same dir.
so on a Linux machine it would be specified as require "./tumblr_client.rb" if it were in the same directory as your program or require "/full/path/of/file/tumblr_client.rb" if not
(Windows paths are different naturally but I wouldn't be surprised if similar rules apply)
i don't know if the Windows distro has a copy of the interactive debugger but probably, it almost certainly won't work in the DOS cmd prompt but try Powershell, open that and type 'irb' which if works will give you a little arrow prompt like this
irb(main):001:0>
typing the name and path of the require statement in here like so :-
irb(main):001:0> require "./whatever.rb"
=> true
irb(main):002:0>
will return true or false, if it returns true like above then it can load the file and uses its contents, false it will tell you why so you can use it to figure out why if at all it can't read this file.
the next steps call some of the included code and passes it a hash which is a list of variables indexed by keys that also doesn't look right to me try it without the colons and smiley faces I think the keys should probably just begin with a lower case letter.
the output of whatever gets returned ends up in the client object
puts client.info (get rid of the quotes) means execute the info method of client and write the output to STDOUT which on Unix would go to console by default unless specified don't know about Windows
Which is another reason why I think you should give Powershell a bash since unlike the DOS prompt it shouldn't close itself after execution
Another thing to try is to replace puts with print, puts automatically adds a \n to end of the output string which is a Unix carriage return, Windows probably doesn't understand that.
 
After all that the tutor emailed to say to use Javascript and P5. So all this has been pointless. The tuition on this coding module has been atrocious; we've seen the feedback, and it's not just J who found it poor. They got the lowest possible mark in nearly every area. Other modules have got better results so it's not just the students marking poorly, either.

So now we've spent the last few days trying to make a bot using Java. It's fucking impossible. ALL the instructions are either for Mac or Linux (and don't mention that explicitly) or are completely incomprehensible. I even booked a tutor to come over and help and they cancelled last minute.

We're sitting here crying because it's so frustrating.
 
After all that the tutor emailed to say to use Javascript and P5. So all this has been pointless. The tuition on this coding module has been atrocious; we've seen the feedback, and it's not just J who found it poor. They got the lowest possible mark in nearly every area. Other modules have got better results so it's not just the students marking poorly, either.

So now we've spent the last few days trying to make a bot using Java. It's fucking impossible. ALL the instructions are either for Mac or Linux (and don't mention that explicitly) or are completely incomprehensible. I even booked a tutor to come over and help and they cancelled last minute.

We're sitting here crying because it's so frustrating.
Java or Javascript?

Explain what you're trying to do and I'll see if I can help (know a bit of both...and python)

*goes to read rest of thread*
 
Java or Javascript?

Explain what you're trying to do and I'll see if I can help (know a bit of both...and python)

*goes to read rest of thread*

Javscript. Also possibly P5.

She has to make a bot that searches for words on twitter or tumblr, then categorises those words as one of six "feelings," then outputs a picture (of a mood ring that she's already made using html and css) to show the "mood" of what she's reading. Honestly I don't think instructions via this thread are going to help, because looking at even the simplest of instructions throws up problems. Like looking at this: How To Create Your Own Twitter Bot, Part 1 (No Programming Required) All looks straightforward, right? But the specific twitter feed account she's basing these instructions on no longer exists. There are others, but their interfaces are different, so every instruction after number 4 is useless. This is the sort of thing that keeps coming up.
 
Javscript. Also possibly P5.

She has to make a bot that searches for words on twitter or tumblr, then categorises those words as one of six "feelings," then outputs a picture (of a mood ring that she's already made using html and css) to show the "mood" of what she's reading. Honestly I don't think instructions via this thread are going to help, because looking at even the simplest of instructions throws up problems. Like looking at this: How To Create Your Own Twitter Bot, Part 1 (No Programming Required) All looks straightforward, right? But the specific twitter feed account she's basing these instructions on no longer exists. There are others, but their interfaces are different, so every instruction after number 4 is useless. This is the sort of thing that keeps coming up.
You're right that this thread alone won't be enough, but part of learning programming is problem solving. That's what programming is.

So you need to break down the problem into steps and solve each one. Then combine the steps into the final program (or bot, in your case). You will have to do lots of searching as you've found...professional programmers do this constantly.

I'd do something like this:

1. Write a small program that takes a text file as input and looks for specific words that you define in the source code. Maybe just outputting the specific word it finds on its own line or something, to ensure it's working.
2. Now extend this program to count the number of occurances of each word and print the totals.
3. Build on this by assigning the words to feelins and output the feeling that has the most number of associated words in the text file.

Once you've got that working, you can then look at connecting to the Tumblr API.

1. Connect to the Tumblr API and print the text from the current page/article
2. Make the small program from the first section into a function and feed the Tumblr text into that function instead

Do the same as the last two steps but for Twitter.

Then after you've done all that, you can look at how to display an image instead of text for the mood that is output.

How long does she have? It's not a trivial program, but it should be doable given some basic programming knowledge and enough time.
 
For example, I decided to have at something supposedly VERY simple. Here: How to Write a Twitter Bot in 5 Minutes

But look at B, step 1. When you click on that link it asks for permissions relating to your Gmail account. I give it permission, but then it just cycles back to the permissions page. So there is nothing I can do. I cannot proceed beyond this step and there's no obvious reason why.
botpermission.png
 
You're right that this thread alone won't be enough, but part of learning programming is problem solving. That's what programming is.

So you need to break down the problem into steps and solve each one. Then combine the steps into the final program (or bot, in your case). You will have to do lots of searching as you've found...professional programmers do this constantly.

I'd do something like this:

1. Write a small program that takes a text file as input and looks for specific words that you define in the source code. Maybe just outputting the specific word it finds on its own line or something, to ensure it's working.
2. Now extend this program to count the number of occurances of each word and print the totals.
3. Build on this by assigning the words to feelins and output the feeling that has the most number of associated words in the text file.

Once you've got that working, you can then look at connecting to the Tumblr API.

1. Connect to the Tumblr API and print the text from the current page/article
2. Make the small program from the first section into a function and feed the Tumblr text into that function instead

Do the same as the last two steps but for Twitter.

Then after you've done all that, you can look at how to display an image instead of text for the mood that is output.

How long does she have? It's not a trivial program, but it should be doable given some basic programming knowledge and enough time.

Ah. Step 1 there is not something she can do. She can't write a programme. Honestly, that's kinda like saying "first, learn to speak French." It's not a minor skill.

This was meant to be a very basic coding course for people with no experience of coding and she will never need to do any coding again.

She has three days left. She has been trying to do it for weeks. It's just not going to happen.
 
For example, I decided to have at something supposedly VERY simple. Here: How to Write a Twitter Bot in 5 Minutes

But look at B, step 1. When you click on that link it asks for permissions relating to your Gmail account. I give it permission, but then it just cycles back to the permissions page. So there is nothing I can do. I cannot proceed beyond this step and there's no obvious reason why.
View attachment 134205
Well, that's a service that makes Twitter bots for you. It's like copy pasting from Wikipedia in terms of a programming assignment.

If she's been asked to write a Twitter bot, then using one of those will probably be a fail.

What's the course? Just so I'm not getting the wrong end of the stick....
 
Ah. Step 1 there is not something she can do. She can't write a programme. Honestly, that's kinda like saying "first, learn to speak French." It's not a minor skill.

This was meant to be a very basic coding course for people with no experience of coding and she will never need to do any coding again.

She has three days left. She has been trying to do it for weeks. It's just not going to happen.
OK, you've just answered my question...ish.

I don't know why she's being asked to do something like this if it's not a programming course.

P5 and Javascript are programming. Writing bots to connect to web APIs is not "very basic coding", IMO.
 
OK, you've just answered my question...ish.

I don't know why she's being asked to do something like this if it's not a programming course.

P5 and Javascript are programming. Writing bots to connect to web APIs is not "very basic coding", IMO.

The course is animation, but this is the only coding course on it.

I couldn't tell how much that bot service would be doing for her - like how much she could customise it to demonstrate some coding. She wasn't planning on pretending she hadn't used it btw.
 
Back
Top Bottom